blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 268 | content_id stringlengths 40 40 | detected_licenses listlengths 0 58 | license_type stringclasses 2 values | repo_name stringlengths 5 118 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 816 values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 2.31k 677M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 151 values | src_encoding stringclasses 33 values | language stringclasses 1 value | is_vendor bool 2 classes | is_generated bool 2 classes | length_bytes int64 3 10.3M | extension stringclasses 119 values | content stringlengths 3 10.3M | authors listlengths 1 1 | author_id stringlengths 0 228 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
edf47d8ad1ffc485b43808ccb0192f7ce289895b | 0e69e11163419b8ab50c60a9e4156034ed377365 | /mst/prim.c | e9b1d1d0e22ad00618c0029da13c72fed49a7a0c | [] | no_license | CodHeK/BaseCodes | c8ad9ab27a7f3cdf7bdecc169c6e5bea9bbc7cf3 | db9087f6b8190b6b3542962791917d61ca8a79eb | refs/heads/master | 2021-01-01T13:35:46.522868 | 2018-06-08T07:29:01 | 2018-06-08T07:29:01 | 97,582,587 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,152 | c | void make_tree(int r, struct edge tree[MAX])
{
int current, i;
int count=0;
for(i=0;i<n;i++)
{
pred[i]=nil;
length[i]=infinity;
status[i]=TEMP;
}
length[r]=0;
while(1)
{
current=min_temp();
if(current==NIL)
{
if(count==n-1)
return;
else
{
printf("graph not connected\n");
exit(1);
}
}
status[current]=PERM;
if(current!=r)
{
count++;
tree[count].u=pred[current];
tree[count].v=current;
}
for(i=0;i<n;i++)
{
if(adj[current][i] && status[i]=TEMP)
{
if(adj[current][i]<length[i])
{
length[i]=adj[current][i];
pred[i]=current;
}
}
}
}
}
int min_temp()
{
int i;
int mins=infinity,k=-1;
for(i=0;i<n;i++)
{
if(status[i]==TEMP && length[i]<mins)
{
mins=length[i];
k=i;
}
}
return k;
}
| [
"gaganganapathyas@yahoo.in"
] | gaganganapathyas@yahoo.in |
011593519efd7453ca52a281e3d4963ced7eb278 | e1562ed5adead92b2a146c123d55da12af47bcf1 | /smilelib/decimal/bid32_add.c | f5b70de0320e1561a2d19a45f28c5e6b648905ef | [
"Apache-2.0",
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | seanofw/smile | 7eaa2ffeacabe12f658c0c79de67a247885bccd3 | 3bc8807513cdb54053134fe2c79c5bf077aa026d | refs/heads/master | 2021-04-12T11:10:14.149628 | 2019-12-31T14:19:34 | 2019-12-31T14:19:34 | 39,726,153 | 15 | 5 | Apache-2.0 | 2019-07-29T02:52:30 | 2015-07-26T13:18:33 | C | UTF-8 | C | false | false | 7,373 | c | /******************************************************************************
Copyright (c) 2007-2011, Intel Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
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.
******************************************************************************/
#define BID_FUNCTION_SETS_BINARY_FLAGS
#include "bid_internal.h"
BID_TYPE_FUNCTION_ARG2(BID_UINT32, bid32_add, x, y)
BID_UINT128 Tmp;
BID_SINT64 S, sign_ab;
BID_UINT64 SU, CB, P, Q, R;
BID_UINT32 sign_x, sign_y, coefficient_x, coefficient_y, res;
BID_UINT32 sign_a, sign_b, coefficient_a, coefficient_b;
BID_UINT32 valid_x, valid_y;
int exponent_x, exponent_y, bin_expon, amount, n_digits, extra_digits, status, rmode;
int exponent_a, exponent_b, scale_ca, diff_dec_expon, d2;
int_double tempx;
BID_OPT_SAVE_BINARY_FLAGS()
valid_x = unpack_BID32 (&sign_x, &exponent_x, &coefficient_x, x);
valid_y = unpack_BID32 (&sign_y, &exponent_y, &coefficient_y, y);
// unpack arguments, check for NaN or Infinity
if (!valid_x) {
// x is Inf. or NaN
// test if x is NaN
if ((x & NAN_MASK32) == NAN_MASK32) {
#ifdef BID_SET_STATUS_FLAGS
if (((x & SNAN_MASK32) == SNAN_MASK32) // sNaN
|| ((y & SNAN_MASK32) == SNAN_MASK32))
__set_status_flags (pfpsf, BID_INVALID_EXCEPTION);
#endif
res = coefficient_x & QUIET_MASK32;
BID_RETURN (res);
}
// x is Infinity?
if ((x & INFINITY_MASK32) == INFINITY_MASK32) {
// check if y is Inf
if (((y & NAN_MASK32) == INFINITY_MASK32)) {
if (sign_x == (y & 0x80000000)) {
res = coefficient_x;
BID_RETURN (res);
}
// return NaN
{
#ifdef BID_SET_STATUS_FLAGS
__set_status_flags (pfpsf, BID_INVALID_EXCEPTION);
#endif
res = NAN_MASK32;
BID_RETURN (res);
}
}
// check if y is NaN
if (((y & NAN_MASK32) == NAN_MASK32)) {
res = coefficient_y & QUIET_MASK32;
#ifdef BID_SET_STATUS_FLAGS
if (((y & SNAN_MASK32) == SNAN_MASK32))
__set_status_flags (pfpsf, BID_INVALID_EXCEPTION);
#endif
BID_RETURN (res);
}
// otherwise return +/-Inf
{
res = coefficient_x;
BID_RETURN (res);
}
}
// x is 0
{
if (((y & INFINITY_MASK32) != INFINITY_MASK32) && coefficient_y) {
if (exponent_y <= exponent_x) {
res = y;
BID_RETURN (res);
}
}
}
}
if (!valid_y) {
// y is Inf. or NaN?
if (((y & INFINITY_MASK32) == INFINITY_MASK32)) {
#ifdef BID_SET_STATUS_FLAGS
if ((y & SNAN_MASK32) == SNAN_MASK32) // sNaN
__set_status_flags (pfpsf, BID_INVALID_EXCEPTION);
#endif
res = coefficient_y & QUIET_MASK32;
BID_RETURN (res);
}
// y is 0
if (!coefficient_x) { // x==0
if (exponent_x <= exponent_y)
res = ((BID_UINT32) exponent_x) << 23;
else
res = ((BID_UINT32) exponent_y) << 23;
if (sign_x == sign_y)
res |= sign_x;
#ifndef IEEE_ROUND_NEAREST_TIES_AWAY
#ifndef IEEE_ROUND_NEAREST
if (rnd_mode == BID_ROUNDING_DOWN && sign_x != sign_y)
res |= 0x80000000;
#endif
#endif
BID_RETURN (res);
} else if (exponent_y >= exponent_x) {
res = x;
BID_RETURN (res);
}
}
// sort arguments by exponent
if (exponent_x < exponent_y) {
sign_a = sign_y;
exponent_a = exponent_y;
coefficient_a = coefficient_y;
sign_b = sign_x;
exponent_b = exponent_x;
coefficient_b = coefficient_x;
} else {
sign_a = sign_x;
exponent_a = exponent_x;
coefficient_a = coefficient_x;
sign_b = sign_y;
exponent_b = exponent_y;
coefficient_b = coefficient_y;
}
// exponent difference
diff_dec_expon = exponent_a - exponent_b;
if (diff_dec_expon > MAX_FORMAT_DIGITS_32) {
tempx.d = (double) coefficient_a;
bin_expon = ((tempx.i & MASK_BINARY_EXPONENT) >> 52) - 0x3ff;
scale_ca = bid_estimate_decimal_digits[bin_expon];
d2 = 16 - scale_ca;
if(diff_dec_expon > d2)
{
diff_dec_expon = d2;
exponent_b = exponent_a - diff_dec_expon;
}
}
sign_ab = ((BID_SINT64)(sign_a ^ sign_b))<<32;
sign_ab = ((BID_SINT64) sign_ab) >> 63;
CB = ((BID_UINT64)coefficient_b + sign_ab) ^ sign_ab;
SU = (BID_UINT64)coefficient_a * bid_power10_table_128[diff_dec_expon].w[0];
S = SU + CB;
if(S<0) {
sign_a ^= 0x80000000;
S = -S;
}
P = S;
if(!P) {
sign_a = 0;
if(rnd_mode == BID_ROUNDING_DOWN) sign_a = 0x80000000;
if(!coefficient_a) sign_a = sign_x;
n_digits=0;
}
else {
tempx.d = (double) P;
bin_expon = ((tempx.i & MASK_BINARY_EXPONENT) >> 52) - 0x3ff;
n_digits = bid_estimate_decimal_digits[bin_expon];
if(P >=bid_power10_table_128[n_digits].w[0])
n_digits++;
}
if(n_digits <= MAX_FORMAT_DIGITS_32) {
res = get_BID32 (sign_a, exponent_b, (BID_UINT32)P, rnd_mode,
pfpsf);
BID_RETURN (res);
}
extra_digits = n_digits - 7;
#ifndef IEEE_ROUND_NEAREST_TIES_AWAY
#ifndef IEEE_ROUND_NEAREST
rmode = rnd_mode;
if (sign_a && (unsigned) (rmode - 1) < 2)
rmode = 3 - rmode;
#else
rmode = 0;
#endif
#else
rmode = 0;
#endif
// add a constant to P, depending on rounding mode
// 0.5*10^(digits_p - 16) for round-to-nearest
P += bid_round_const_table[rmode][extra_digits];
__mul_64x64_to_128(Tmp, P, bid_reciprocals10_64[extra_digits]);
// now get P/10^extra_digits: shift Q_high right by M[extra_digits]-64
amount = bid_short_recip_scale[extra_digits];
Q = Tmp.w[1] >> amount;
// remainder
R = P - Q * bid_power10_table_128[extra_digits].w[0];
if(R==bid_round_const_table[rmode][extra_digits])
status = 0;
else status = BID_INEXACT_EXCEPTION;
#ifdef BID_SET_STATUS_FLAGS
__set_status_flags (pfpsf, status);
#endif
#ifndef IEEE_ROUND_NEAREST_TIES_AWAY
#ifndef IEEE_ROUND_NEAREST
if (rmode == 0) //BID_ROUNDING_TO_NEAREST
#endif
if(R==0)
Q &= 0xfffffffe;
#endif
res = get_BID32 (sign_a, exponent_b+extra_digits, Q, rnd_mode, pfpsf);
BID_RETURN (res);
}
| [
"sean@werkema.com"
] | sean@werkema.com |
ff0b96005345669d72c86cd3bf928b1acc7710a5 | 681de63382029d7cf66e59388f51403e65d5a51c | /metadata_input_munin.c | 59eba1ea465a87c5dbe651dedb02b7f668e5c7b5 | [
"BSD-2-Clause"
] | permissive | NEAT-project/data-exporter | e61ce1bdea6e9d93216c5f72defd13a9e71f5a5a | 2873652f8bddc65393c3a04a72c9452f7e78b242 | refs/heads/master | 2021-01-23T08:04:33.483810 | 2017-01-31T14:02:04 | 2017-01-31T14:02:04 | 80,525,464 | 0 | 0 | null | 2017-01-31T14:02:36 | 2017-01-31T14:02:36 | null | UTF-8 | C | false | false | 8,672 | c | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/time.h>
#include <sys/timerfd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <unistd.h>
#include <getopt.h>
#include "metadata_exporter.h"
#include "metadata_input_munin.h"
#include "backend_event_loop.h"
/* polling interval in seconds */
#define MUNIN_POLLING_INTERVAL 5
/* TODO
- handle socket disconnect/reconnect
*/
ssize_t md_munin_readLine(int fd, void *buffer, size_t n)
{
ssize_t numRead;
size_t totRead;
char *buf;
char ch;
if (n <= 0 || buffer == NULL) {
errno = EINVAL;
return -1;
}
buf = buffer;
totRead = 0;
for (;;) {
numRead = read(fd, &ch, 1);
if (numRead == -1) {
if (errno == EINTR)
continue;
else
return -1;
} else if (numRead == 0) {
if (totRead == 0)
return 0;
else
break;
} else {
if (totRead < n - 1) {
totRead++;
*buf++ = ch;
}
if (ch == '\n')
break;
}
}
*buf = '\0';
return totRead;
}
uint8_t md_munin_reconnect (struct md_input_munin *mim, const char *address, const char *port) {
int n = -1;
char buffer[256] = "\n";
struct hostent* server;
struct sockaddr_in serv_addr;
if ((mim->munin_socket_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "Error opening socket.\n");
return RETVAL_FAILURE;
}
if ((server = gethostbyname(address)) == NULL) {
fprintf(stderr, "No such host: %s\n", address);
return RETVAL_FAILURE;
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
serv_addr.sin_port = htons(atoi(port));
if (connect(mim->munin_socket_fd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) {
fprintf(stderr, "Could not connect to munin.\n");
return RETVAL_FAILURE;
}
if ((n = md_munin_readLine(mim->munin_socket_fd, buffer, 255))<0) {
fprintf(stderr, "Could not read munin welcome string.\n");
close(mim->munin_socket_fd);
return RETVAL_FAILURE;
}
printf("%s", buffer);
return RETVAL_SUCCESS;
}
void md_munin_json_add_key_value(char* kv, json_object* blob) {
char *running = kv;
// a munin string is in the form uptime.value 1.23
char *key = strsep(&running, ".");
if (running == NULL) {
fprintf(stderr, "Munin return line did not match format key.value value\n");
return;
}
char *svalue = strsep(&running, " "); //ignore .value
if (running == NULL || (strncmp(svalue, "value", 5)!=0) ) {
fprintf(stderr, "Munin return line did not match format key.value value\n");
return;
}
char *value = strsep(&running, "\n");
struct json_object *obj_add = NULL;
if ((obj_add = json_object_new_string(value))==NULL)
return;
json_object_object_add(blob, key, obj_add);
}
static void md_input_munin_handle_event(void *ptr, int32_t fd, uint32_t events)
{
struct md_input_munin *mim = ptr;
int i=0,n;
uint64_t exp;
if ((n=read(fd, &exp, sizeof(uint64_t))) < sizeof(uint64_t)) {
fprintf(stderr, "Munin timer failed.\n");
return;
}
setsockopt( mim->munin_socket_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i));
struct json_object *blob = NULL;
struct timeval tv;
if (!(blob = json_object_new_object()))
return;
for (i=0; i < mim->module_count; i++) {
char cmd[256];
char buffer[256];
snprintf(cmd, 255, "fetch %s\n", mim->modules[i]);
if ((n=write(mim->munin_socket_fd, cmd, strlen(cmd)))<0) {
fprintf(stderr, "Writing to munin failed.\n");
return;
}
struct json_object *obj_mod = NULL;
if (!(obj_mod = json_object_new_object()))
break;
json_object_object_add(blob, mim->modules[i], obj_mod);
while (1) {
if ((n=md_munin_readLine(mim->munin_socket_fd, buffer, 255))<0) {
fprintf(stderr, "Reading from munin failed.\n");
return;
}
if ((buffer[0] == '#') || (buffer[0] == '.'))
break;
md_munin_json_add_key_value(buffer, obj_mod);
}
}
struct md_munin_event munin_event;
memset(&munin_event, 0, sizeof(struct md_munin_event));
gettimeofday(&tv, NULL);
munin_event.md_type = META_TYPE_MUNIN;
munin_event.tstamp = tv.tv_sec;
munin_event.sequence = mde_inc_seq(mim->parent);
munin_event.json_blob = blob;
//fprintf(stderr, "JSON dump: %s\n", json_object_to_json_string(blob));
mde_publish_event_obj(mim->parent, (struct md_event *) &munin_event);
json_object_put(blob);
}
static uint8_t md_munin_config(struct md_input_munin *mim,
const char *address,
const char *port,
const char *modules)
{
int timer;
struct itimerspec delay;
if (md_munin_reconnect(mim, address, port) == RETVAL_SUCCESS) {
char *running;
if ((running = strdup(modules)) == NULL) {
fprintf(stderr, "Memory allocation failed.");
return RETVAL_FAILURE;
}
char **tokens = NULL;
char * token = strsep(&running, ",");
int n_commas = 0,
n_tokens = 0;
while(token) {
if ((tokens = realloc(tokens, sizeof(char*)* ++n_commas))==NULL) {
fprintf(stderr, "Memory allocation failed.");
return RETVAL_FAILURE;
}
tokens[n_commas-1] = token;
token = strsep(&running, ",");
n_tokens++;
}
mim->module_count = n_tokens;
mim->modules = tokens;
if ((timer = timerfd_create(CLOCK_REALTIME, 0)) < 0) {
fprintf(stderr, "Could not create munin polling timer.");
return RETVAL_FAILURE;
}
delay.it_value.tv_sec = MUNIN_POLLING_INTERVAL;
delay.it_value.tv_nsec = 0;
delay.it_interval.tv_sec = MUNIN_POLLING_INTERVAL;
delay.it_interval.tv_nsec = 0;
if (timerfd_settime(timer, TFD_TIMER_ABSTIME, &delay, NULL) < 0) {
fprintf(stderr, "Could not initialize munin polling timer.");
return RETVAL_FAILURE;
}
if(!(mim->event_handle = backend_create_epoll_handle(
mim, timer, md_input_munin_handle_event)))
return RETVAL_FAILURE;
backend_event_loop_update(
mim->parent->event_loop, EPOLLIN, EPOLL_CTL_ADD, timer, mim->event_handle);
return RETVAL_SUCCESS;
} else {
return RETVAL_FAILURE;
}
}
void md_input_munin_destroy(void *ptr)
{
struct md_input_munin *mim = ptr;
if ((mim != NULL) && (mim->module_count > 0)) {
free(mim->modules);
mim->module_count = 0;
}
}
static uint8_t md_input_munin_init(void *ptr, json_object* config)
{
struct md_input_munin *mim = ptr;
const char *address = NULL, *port = NULL;
const char *modules = "memory,cpu";
json_object* subconfig;
if (json_object_object_get_ex(config, "munin", &subconfig)) {
json_object_object_foreach(subconfig, key, val) {
if (!strcmp(key, "address"))
address = json_object_get_string(val);
else if (!strcmp(key, "port"))
port = json_object_get_string(val);
else if (!strcmp(key, "modules"))
modules = json_object_get_string(val);
}
}
if (address == NULL || port == NULL) {
fprintf(stderr, "Missing required Munin argument\n");
return RETVAL_FAILURE;
}
return md_munin_config(mim, address, port, modules);
}
void md_munin_usage()
{
fprintf(stderr, "\"munin\": {\t\tMunin input\n");
// TODO: --munin-binary (no need to run systemd, nginx or inetd)
fprintf(stderr, " \"address\":\t\tmunin address\n");
fprintf(stderr, " \"port\":\t\tmunin port\n");
// TODO: change comma separated modules into a JSON array
fprintf(stderr, " \"modules\":\t\tcomma separated, modules to export\n");
fprintf(stderr, "},\n");
}
void md_munin_setup(struct md_exporter *mde, struct md_input_munin *mim)
{
mim->parent = mde;
mim->init = md_input_munin_init;
mim->destroy = md_input_munin_destroy;
}
| [
"thomas.hirsch@celerway.com"
] | thomas.hirsch@celerway.com |
0eb51b5593bb505e9345fd8924e85c06cc6591f6 | 4d975c23bc1e48d4efa57ca1549768a114932488 | /tests/test-simple.c | 9b6a7ffc9409f577c53525536d6b8be47736809c | [
"MIT"
] | permissive | Emman-B/dymat-c | a3488eca95ca566802a72f9daa6491b728e10fad | f69896f6ce7017e4c24345133a0b3a53b0f8d744 | refs/heads/master | 2020-09-03T22:40:12.854611 | 2019-12-18T10:25:58 | 2019-12-18T10:25:58 | 219,591,825 | 1 | 0 | null | null | null | null | UTF-8 | C | false | false | 2,497 | c | // Written by Emmanuel Butor
// test1-simple.c
// Tests all of the public methods defined in dymat.h
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "../src/dymat.h" // relative to where this file is located compared to where "dymat.h" is
int main()
{
printf("Running TEST_PUBLIC1.c\n\n");
printf("All tests will run destroy_dymatobj() after each test.\n\n");
// TEST1: t_malloc
{
printf("[TEST1] Initiate Test\n");
int* x = t_malloc(sizeof(int));
*x = 50;
printf("[TEST1] integer pointer x has value %d, 50 is expected\n", *x);
assert(*x == 50);
destroy_dymatobj();
}
// TEST2: t_calloc
{
printf("\n[TEST2] Initiate Test\n");
int* array = t_calloc(4, sizeof(int));
array[0] = 5;
array[1] = 10;
array[2] = 20;
array[3] = -10;
printf("[TEST2] Array of 4 integers have been created.\n");
printf("[TEST2] array[0] = %d, 5 is expected.\n", array[0]);
assert(array[0] == 5);
printf("[TEST2] array[1] = %d, 10 is expected.\n", array[1]);
assert(array[1] == 10);
printf("[TEST2] array[2] = %d, 20 is expected.\n", array[2]);
assert(array[2] == 20);
printf("[TEST2] array[3] = %d, -10 is expected.\n", array[3]);
assert(array[3] == -10);
destroy_dymatobj();
}
// TEST3: t_free and is_null
{
printf("\n[TEST3] Initiate Test\n");
int* x = t_malloc(sizeof(int));
printf("[TEST3] Check: is x null? returned %s, false is expected.\n", (is_null(x)?"true":"false") );
assert(!is_null(x));
t_free(x);
printf("[TEST3] Check: is x null? returned %s, true is expected.\n", (is_null(x)?"true":"false") );
assert(is_null(x));
destroy_dymatobj();
}
// TEST4: freeall
{
printf("\n[TEST4] Initiate Test\n");
int* x1 = t_malloc(sizeof(int));
int* x2 = t_calloc(1, sizeof(int));
int* array = t_calloc(16, sizeof(int));
printf("[TEST4] Check x1, x2, array if any are null. At this step, none should be null.\n");
assert(!is_null(x1));
assert(!is_null(x2));
assert(!is_null(array));
freeall();
printf("[TEST4] freeall() has been called. Now check if x1, x2, array are null. All should be null.\n");
assert(is_null(x1));
assert(is_null(x2));
assert(is_null(array));
destroy_dymatobj();
}
} | [
"emmanuelbutor.mehs@gmail.com"
] | emmanuelbutor.mehs@gmail.com |
3bb12df25308aab1fe07d3c52853243c2ca06dab | d944d10c34df5c1418ba0a768162b885fb127d66 | /libft/ft_strdup.c | ad71fbe332fba7de7cb74048085f5d532101b4c0 | [] | no_license | VirtualNovice/virtualLibft | 96a8d1410b1fccf34e19accb14fa6bf3f391e6eb | 855912d4c06097dd553c9181481c443f6a6f00bd | refs/heads/main | 2023-08-23T13:22:12.164588 | 2021-11-04T16:09:50 | 2021-11-04T16:09:50 | 420,443,018 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,116 | c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oumali <oumali@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/18 16:20:11 by oumali #+# #+# */
/* Updated: 2021/10/18 16:36:20 by oumali ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
int slen;
char *str;
slen = ft_strlen(s1);
str = (char *)ft_calloc(slen + 1, sizeof(char));
if (!str)
return (NULL);
ft_memcpy(str, s1, slen);
return (str);
}
| [
"noreply@github.com"
] | VirtualNovice.noreply@github.com |
2734f4795dd9dcb749948cb7294d9b359c4e0e43 | 976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f | /source/linux/sound/usb/hiface/extr_pcm.c_hiface_pcm_free.c | 033ff6588d64fa083cc23fb5f9b8f83f4cfc28b7 | [] | no_license | isabella232/AnghaBench | 7ba90823cf8c0dd25a803d1688500eec91d1cf4e | 9a5f60cdc907a0475090eef45e5be43392c25132 | refs/heads/master | 2023-04-20T09:05:33.024569 | 2021-05-07T18:36:26 | 2021-05-07T18:36:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 721 | c | #define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct snd_pcm {struct pcm_runtime* private_data; } ;
struct pcm_runtime {int /*<<< orphan*/ chip; } ;
/* Variables and functions */
int /*<<< orphan*/ hiface_pcm_destroy (int /*<<< orphan*/ ) ;
__attribute__((used)) static void hiface_pcm_free(struct snd_pcm *pcm)
{
struct pcm_runtime *rt = pcm->private_data;
if (rt)
hiface_pcm_destroy(rt->chip);
} | [
"brenocfg@gmail.com"
] | brenocfg@gmail.com |
99dc314696c197546641a21a1a175d59fd44bc63 | 50aafb31f98127487c988319c5d4394e507f7788 | /src/gpre/hsh.h | c020c00d6f61a98425890920c354bd9e7314d05f | [] | no_license | murilofurquim/CorrecaoFirebirdOrdem | 8f3b2d7d9628a760f5d19cd35e040c432eefb0e5 | 07c84c393c6bcd68e07f9655da651b6e21abbbcf | refs/heads/master | 2020-09-10T17:29:02.360601 | 2019-11-21T16:49:36 | 2019-11-21T16:49:36 | 221,778,772 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 11,974 | h | /*
* The contents of this file are subject to the Interbase Public
* License Version 1.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.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* 2007.05.23 Stephen W. Boyd - Added SKIP keyword
* 2007.06.15 Stephen W. Boyd - Added CURRENT_CONNECTION, CURRENT_ROLE,
* CURRENT_TRANSACTION and CURRENT_USER keywords
*/
/* Sort this file with "sort -b +1 +0" */
{"ABNORMAL", KW_ABNORMAL},
#ifdef SCROLLABLE_CURSORS
{"ABSOLUTE", KW_ABSOLUTE},
#endif
{"ACCEPTING", KW_ACCEPTING},
{"ACTION", KW_ACTION},
{"ACTIVE", KW_ACTIVE},
{"ADD", KW_ADD},
{"ALL", KW_ALL},
{"ALLOCATION", KW_ALLOCATION},
{"ALTER", KW_ALTER},
{"&", KW_AMPERSAND},
{"&&", KW_AND},
{"AND", KW_AND},
{"ANY", KW_ANY},
{"SOME", KW_ANY},
{"ANYCASE", KW_ANYCASE},
{"ARE", KW_ARE},
{"AS", KW_AS},
{"ASC", KW_ASCENDING},
{"ASCENDING", KW_ASCENDING},
{"*", KW_ASTERISK},
{"AT", KW_AT},
{"AUTO", KW_AUTO},
{"AUTOCOMMIT", KW_AUTOCOMMIT},
{"AVERAGE", KW_AVERAGE},
{"AVG", KW_AVERAGE},
{"\\", KW_BACK_SLASH},
{"BASED", KW_BASED},
{"BASED_ON", KW_BASED},
{"BASE_NAME", KW_BASE_NAME},
{"BEGIN", KW_BEGIN},
{"BETWEEN", KW_BETWEEN},
{"BT", KW_BETWEEN},
{"BLOB", KW_BLOB},
{"BUFFERCOUNT", KW_BUFFERCOUNT},
{"BUFFERS", KW_BUFFERS},
{"BUFFERSIZE", KW_BUFFERSIZE},
{"BY", KW_BY},
{"CACHE", KW_CACHE},
{"CANCEL_BLOB", KW_CANCEL_BLOB},
{"^", KW_CARAT},
{"CASCADE", KW_CASCADE},
{"CASE", KW_CASE},
{"CAST", KW_CAST},
{"CHAR", KW_CHAR},
{"CHARACTER", KW_CHAR},
{"char", KW_CHAR},
{"CHECK", KW_CHECK},
{"CHECK_POINT_LENGTH", KW_CHECK_POINT_LEN},
{"CLEAR_HANDLES", KW_CLEAR_HANDLES},
{"CLOSE", KW_CLOSE},
{"CLOSE_BLOB", KW_CLOSE_BLOB},
{"COLLATE", KW_COLLATE},
{":", KW_COLON},
{",", KW_COMMA},
{"COMMENT", KW_COMMENT},
{"COMMIT", KW_COMMIT},
{"COMMIT_TRANSACTION", KW_COMMIT},
{"COMMIT_TRANSACTIONS", KW_COMMIT},
{"COMMITTED", KW_COMMITTED},
{"COMPILETIME", KW_COMPILETIME},
{"COMPILE_TIME", KW_COMPILETIME},
{"COMPUTED", KW_COMPUTED},
{"CONCURRENCY", KW_CONCURRENCY},
{"CONDITIONAL", KW_CONDITIONAL},
{"CONNECT", KW_CONNECT},
{"CONSISTENCY", KW_CONSISTENCY},
{"CONSTRAINT", KW_CONSTRAINT},
{"CONTAINING", KW_CONTAINING},
{"CONTINUE", KW_CONTINUE},
{"COUNT", KW_COUNT},
{"CREATE", KW_CREATE},
{"CREATE_BLOB", KW_CREATE_BLOB},
{"CROSS", KW_CROSS},
{"CSTRING", KW_CSTRING},
{"CURRENT", KW_CURRENT},
{"CURRENT_DATE", KW_CURRENT_DATE},
{"CURRENT_TIME", KW_CURRENT_TIME},
{"CURRENT_TIMESTAMP", KW_CURRENT_TIMESTAMP},
{"CURSOR", KW_CURSOR},
{"DATABASE", KW_DATABASE},
{"DATE", KW_DATE},
{"DAY", KW_DAY},
{"DBA", KW_DBA},
{"RDB$DB_KEY", KW_DBKEY},
{"--", KW_DEC},
{"DEC", KW_DECIMAL},
{"DECIMAL", KW_DECIMAL},
{"DECLARE", KW_DECLARE},
{"DEFAULT", KW_DEFAULT},
{"DELETE", KW_DELETE},
{"DERIVED_FROM", KW_DERIVED_FROM},
{"DESC", KW_DESCENDING},
{"DESCENDING", KW_DESCENDING},
{"DESCRIBE", KW_DESCRIBE},
{"DESCRIPTOR", KW_DESCRIPTOR},
{"DIALECT", KW_DIALECT},
{"DISCONNECT", KW_DISCONNECT},
{"DISTINCT", KW_DISTINCT},
{".", KW_DOT},
{"..", KW_DOT_DOT},
{"DOMAIN", KW_DOMAIN},
{"DOUBLE", KW_DOUBLE},
{"double", KW_DOUBLE},
{"DROP", KW_DROP},
{"ELEMENT", KW_ELEMENT},
{"ELSE", KW_ELSE},
{"else", KW_ELSE},
{"END", KW_END},
{"END_ERROR", KW_END_ERROR},
{"END-EXEC", KW_END_EXEC},
{"END_EXEC", KW_END_EXEC},
{"END_FETCH", KW_END_FETCH},
{"END_FOR", KW_END_FOR},
{"END_MODIFY", KW_END_MODIFY},
{"END_STORE", KW_END_STORE},
{"END_STORE_SPECIAL", KW_END_STORE_SPECIAL},
{"END_STREAM", KW_END_STREAM},
{"ENTRY_POINT", KW_ENTRY_POINT},
{"==", KW_EQ},
{"EQ", KW_EQ},
{"=", KW_EQUALS},
{"ERASE", KW_ERASE},
{"ERROR", KW_ERROR},
{"ESCAPE", KW_ESCAPE},
{"EVENT", KW_EVENT},
{"EVENT_INIT", KW_EVENT_INIT},
{"EVENT_WAIT", KW_EVENT_WAIT},
{"EXACTCASE", KW_EXACTCASE},
{"EXCLUSIVE", KW_EXCLUSIVE},
{"EXEC", KW_EXEC},
{"EXECUTE", KW_EXECUTE},
{"EXISTS", KW_EXISTS},
{"EXTERN", KW_EXTERN},
{"EXTERNAL", KW_EXTERNAL},
{"EXTRACT", KW_EXTRACT},
{"FETCH", KW_FETCH},
{"FILE", KW_FILE},
{"FILENAME", KW_FILENAME},
{"FILTER", KW_FILTER},
{"FINISH", KW_FINISH},
{"FINISH_DATABASE", KW_FINISH},
{"FIRST", KW_FIRST},
{"FLOAT", KW_FLOAT},
{"float", KW_FLOAT},
{"FOR", KW_FOR},
{"FOREIGN", KW_FOREIGN},
{"FORWARD", KW_FORWARD},
{"FOUND", KW_FOUND},
{"FROM", KW_FROM},
{"FULL", KW_FULL},
{"FUNCTION", KW_FUNCTION},
{">=", KW_GE},
{"GE", KW_GE},
{"^<", KW_GE},
{"!<", KW_GE},
{"~<", KW_GE},
{"GEN_ID", KW_GEN_ID},
{"GENERATOR", KW_GENERATOR},
{"GET_SEGMENT", KW_GET_SEGMENT},
{"GET_SLICE", KW_GET_SLICE},
{"GLOBAL", KW_GLOBAL},
{"GO", KW_GO},
{"GOTO", KW_GOTO},
{"GRANT", KW_GRANT},
{"GROUP", KW_GROUP},
{"GROUP_COMMIT_WAIT_TIME", KW_GROUP_COMMIT_WAIT},
{">", KW_GT},
{"GT", KW_GT},
{"HANDLES", KW_HANDLES},
{"HAVING", KW_HAVING},
{"HEIGHT", KW_HEIGHT},
{"HORIZONTAL", KW_HORIZONTAL},
{"HOUR", KW_HOUR},
{"IMMEDIATE", KW_IMMEDIATE},
{"IN", KW_IN},
{"INACTIVE", KW_INACTIVE},
{"INIT", KW_INIT},
{"++", KW_INC},
{"INCLUDE", KW_INCLUDE},
{"INDEX", KW_INDEX},
{"INDICATOR", KW_INDICATOR},
{"INNER", KW_INNER},
{"INPUT", KW_INPUT},
{"INPUT_TYPE", KW_INPUT_TYPE},
{"INSERT", KW_INSERT},
{"INT", KW_INT},
{"int", KW_INT},
{"INTEGER", KW_INTEGER},
{"INTERNAL", KW_INTERNAL},
{"INTO", KW_INTO},
{"IS", KW_IS},
{"ISO", KW_ISOLATION},
{"ISOLATION", KW_ISOLATION},
{"JOIN", KW_JOIN},
{"KEY", KW_KEY},
#ifdef SCROLLABLE_CURSORS
{"LAST", KW_LAST},
#endif
{"LC_CTYPE", KW_LC_CTYPE},
{"LC_MESSAGES", KW_LC_MESSAGES},
{"<=", KW_LE},
{"LE", KW_LE},
{"^>", KW_LE},
{"~>", KW_LE},
{"!>", KW_LE},
{"LEFT", KW_LEFT},
{"(", KW_LEFT_PAREN},
{"LENGTH", KW_LENGTH},
{"LEVEL", KW_LEVEL},
{"LIKE", KW_LIKE},
{"LOCK", KW_LOCK},
{"LOG_BUFFER_SIZE", KW_LOG_BUF_SIZE},
{"LOGFILE", KW_LOG_FILE},
{"LONG", KW_LONG},
{"long", KW_LONG},
{"<", KW_LT},
{"LT", KW_LT},
{"{", KW_L_BRACE},
{"[", KW_L_BRCKET},
{"MAIN", KW_MAIN},
{"MANUAL", KW_MANUAL},
{"MATCHES", KW_MATCHES},
{"MATCHING", KW_MATCHES},
{"MAX", KW_MAX},
{"MAXIMUM_SEGMENT", KW_MAX_SEGMENT},
{"MERGE", KW_MERGE},
{"MIN", KW_MIN},
{"MINUTE", KW_MINUTE},
{"-", KW_MINUS},
{"MISSING", KW_MISSING},
{"MODIFY", KW_MODIFY},
{"MODULE_NAME", KW_MODULE_NAME},
{"MONTH", KW_MONTH},
{"NAME", KW_NAME},
{"NAMES", KW_NAMES},
{"namespace", KW_NAMESPACE},
{"NATIONAL", KW_NATIONAL},
{"NATURAL", KW_NATURAL},
{"NCHAR", KW_NCHAR},
{"!=", KW_NE}, {"<>", KW_NE}, {"NE", KW_NE}, {"^=", KW_NE}, {"~=", KW_NE},
#ifdef SCROLLABLE_CURSORS
{"NEXT", KW_NEXT},
#endif
{"NO", KW_NO},
{"NOT", KW_NOT},
{"NO_AUTO_UNDO", KW_NO_AUTO_UNDO},
{"NOWAIT", KW_NO_WAIT},
{"NO_WAIT", KW_NO_WAIT},
{"NO_WAIT", KW_NO_WAIT},
{"NULL", KW_NULL},
{"NUMERIC", KW_NUMERIC},
{"NUM_LOG_BUFFERS", KW_NUM_LOG_BUFS},
{"OF", KW_OF},
{"ON", KW_ON},
{"ON_ERROR", KW_ON_ERROR},
{"ONLY", KW_ONLY},
{"OPAQUE", KW_OPAQUE},
{"OPEN", KW_OPEN},
{"OPEN_BLOB", KW_OPEN_BLOB},
{"OPTION", KW_OPTION},
{"OPTIONS", KW_OPTIONS},
{"OR", KW_OR},
{"||", KW_OR1},
{"ORDER", KW_ORDER},
{"OUTER", KW_OUTER},
{"OUTPUT", KW_OUTPUT},
{"OUTPUT_TYPE", KW_OUTPUT_TYPE},
{"OVER", KW_OVER},
{"OVERFLOW", KW_OVERFLOW},
{"OVERRIDING", KW_OVERRIDING},
{"PAGE", KW_PAGE},
{"PAGES", KW_PAGES},
{"PAGESIZE", KW_PAGESIZE},
{"PAGE_SIZE", KW_PAGE_SIZE},
{"PARAMETER", KW_PARAMETER},
{"PASSWORD", KW_PASSWORD},
{"PATHNAME", KW_PATHNAME},
{"+", KW_PLUS},
{"->", KW_POINTS},
{"PLAN", KW_PLAN},
{"PRECISION", KW_PRECISION},
{"precision", KW_PRECISION},
{"PREPARE", KW_PREPARE},
{"PREPARE_TRANSACTION", KW_PREPARE},
{"PRIMARY", KW_PRIMARY},
#ifdef SCROLLABLE_CURSORS
{"PRIOR", KW_PRIOR},
#endif
{"PRIVILEGES", KW_PRIVILEGES},
{"PROC", KW_PROC},
{"PROCEDURE", KW_PROCEDURE},
{"PROTECTED", KW_PROTECTED},
{"PUBLIC", KW_PUBLIC},
{"PUT_SEGMENT", KW_PUT_SEGMENT},
{"PUT_SLICE", KW_PUT_SLICE},
{"QUADWORD", KW_QUAD},
{"RAW_PARTITIONS", KW_RAW_PARTITIONS},
{"READ", KW_READ},
{"READ_COMMITTED", KW_READ_COMMITTED},
{"READY", KW_READY},
{"READY_DATABASE", KW_READY},
{"READ_ONLY", KW_READ_ONLY},
{"READ_WRITE", KW_READ_WRITE},
{"REAL", KW_REAL},
{"RECORD_VERSION", KW_VERSION},
{"REDUCED", KW_REDUCED},
{"REFERENCES", KW_REFERENCES},
#ifdef SCROLLABLE_CURSORS
{"RELATIVE", KW_RELATIVE},
#endif
{"RELEASE", KW_RELEASE},
{"RELEASE_REQUESTS", KW_RELEASE_REQUESTS},
{"REM", KW_REM},
{"REQUEST_HANDLE", KW_REQUEST_HANDLE},
{"RESERVING", KW_RESERVING},
{"RESOURCE", KW_RESOURCE},
{"RESTRICT", KW_RESTRICT},
{"RETAIN", KW_RETAIN},
{"RETURNING", KW_RETURNING},
{"RETURNING_VALUES", KW_RETURNING_VALUES},
{"RETURNS", KW_RETURNS},
{"REVOKE", KW_REVOKE},
{"RIGHT", KW_RIGHT},
{")", KW_RIGHT_PAREN},
{"ROLE", KW_ROLE},
{"ROLLBACK", KW_ROLLBACK},
{"ROLLBACK_TRANSACTION", KW_ROLLBACK},
{"^FUNCTION", KW_ROUTINE_PTR},
{"^PROCEDURE", KW_ROUTINE_PTR},
{"RUN", KW_RUN},
{"RUNTIME", KW_RUNTIME},
{"}", KW_R_BRACE},
{"]", KW_R_BRCKET},
{"SAVE", KW_SAVE},
{"SAVE_TRANSACTION", KW_SAVE},
{"SAVE_TRANSACTIONS", KW_SAVE},
{"SCALE", KW_SCALE},
{"SCHEDULE", KW_SCHEDULE},
{"SCHEMA", KW_SCHEMA},
#ifdef SCROLLABLE_CURSORS
{"SCROLL", KW_SCROLL},
#endif
{"SECTION", KW_SECTION},
{"SECOND", KW_SECOND},
{"SEGMENT", KW_SEGMENT},
{"SELECT", KW_SELECT},
{";", KW_SEMI_COLON},
{"SET", KW_SET},
{"SHARED", KW_SHARED},
{"SHADOW", KW_SHADOW},
{"SHORT", KW_SHORT},
{"short", KW_SHORT},
{"SINGULAR", KW_SINGULAR},
{"SIZE", KW_SIZE},
{"/", KW_SLASH},
{"SMALLINT", KW_SMALLINT},
{"SNAPSHOT", KW_SNAPSHOT},
{"SORT", KW_SORT},
{"SORTED", KW_SORTED},
{"SQL", KW_SQL},
{"SQLERROR", KW_SQLERROR},
{"SQLWARNING", KW_SQLWARNING},
{"STABILITY", KW_STABILITY},
{"STARTING", KW_STARTING},
{"STARTING_WITH", KW_STARTING_WITH},
{"STARTS", KW_STARTS},
{"START_STREAM", KW_START_STREAM},
{"START_TRANSACTION", KW_START_TRANSACTION},
{"STATE", KW_STATE},
{"STATEMENT", KW_STATEMENT},
{"STATIC", KW_STATIC},
{"STATISTICS", KW_STATISTICS},
{"STOGROUP", KW_STOGROUP},
{"STORE", KW_STORE},
{"STREAM", KW_STREAM},
{"STRING", KW_STRING},
{"SUB", KW_SUB},
{"SUB_TYPE", KW_SUB_TYPE},
{"SUBROUTINE", KW_SUBROUTINE},
{"SUM", KW_SUM},
{"SYNONYM", KW_SYNONYM},
{"TABLE", KW_TABLE},
{"TABLESPACE", KW_TABLESPACE},
{"TAG", KW_TAG},
{"TERMINATING_FIELD", KW_TERMINATING_FIELD},
{"TERMINATOR", KW_TERMINATOR},
{"TIME", KW_TIME},
{"TIMESTAMP", KW_TIMESTAMP},
{"TITLE_LENGTH", KW_TITLE_LENGTH},
{"TITLE_TEXT", KW_TITLE_TEXT},
{"TO", KW_TO},
{"TOTAL", KW_TOTAL},
{"TRANSACTION", KW_TRANSACTION},
{"TRANSACTION_HANDLE", KW_TRANSACTION_HANDLE},
{"TRANSPARENT", KW_TRANSPARENT},
{"TRIGGER", KW_TRIGGER},
{"UNCOMMITTED", KW_UNCOMMITTED},
{"UNION", KW_UNION},
{"UNIQUE", KW_UNIQUE},
{"UPDATE", KW_UPDATE},
{"UPPER", KW_UPPER},
{"UPPERCASE", KW_UPPERCASE},
{"USER", KW_USER},
{"USERS", KW_USERS},
{"RDB$USER_NAME", KW_USER_NAME},
{"USING", KW_USING},
{"VALUE", KW_VALUE},
{"VALUES", KW_VALUES},
{"VAL_PARAM", KW_VAL_PARAM},
{"VARCHAR", KW_VARCHAR},
{"VARIABLE", KW_VARIABLE},
{"VARYING", KW_VARYING},
{"VERTICAL", KW_VERTICAL},
{"VIEW", KW_VIEW},
{"WAIT", KW_WAIT},
{"WAKING", KW_WAKING},
{"WARNING", KW_WARNING},
{"WEEKDAY", KW_WEEKDAY},
{"WHENEVER", KW_WHENEVER},
{"WIDTH", KW_WIDTH},
{"WHERE", KW_WITH},
{"WITH", KW_WITH},
{"WORK", KW_WORK},
{"WRITE", KW_WRITE},
{"YEAR", KW_YEAR},
{"YEARDAY", KW_YEARDAY},
{"SKIP", KW_SKIP},
{"CURRENT_CONNECTION", KW_CURRENT_CONNECTION},
{"CURRENT_ROLE", KW_CURRENT_ROLE},
{"CURRENT_TRANSACTION", KW_CURRENT_TRANSACTION},
{"CURRENT_USER", KW_CURRENT_USER}
| [
"murilofurquim@gmail.com"
] | murilofurquim@gmail.com |
9765be9f430c997ba508ab838160f17b9ff3b92e | 59f48d505480ce52dee685c8a2a0bd49b7c81737 | /RF_Handshaking/ssp.c | d091308e43f37e725d256f093c0a0bbf068baf69 | [] | no_license | vatsalm93/CMPE-245-Implementation-of-Cognitive-Radio-LISA-LoRA | 5db5680f8e7361a14abfe8bb4135a141254cfef2 | fc7c3819902fda62bbbaab0de555577e8b7950c9 | refs/heads/master | 2022-10-20T18:26:18.082682 | 2020-06-10T23:15:57 | 2020-06-10T23:15:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 4,257 | c | /*
* spi.cpp
*
* Created on: Oct 29, 2017
* CTI One Corporation released for Dr. Harry Li for CMPE 245 Class use ONLY!
*/
#include "ssp.h"
//#define CHIP_SELECT (LPC_GPIO0->FIOCLR |= (0x1<<6))
//#define CHIP_DESELECT (LPC_GPIO0->FIOSET |= (0x1<<6))
#define SSP_BUFSIZE 128
/* statistics of all the interrupts */
volatile uint32_t interrupt0RxStat = 0;
volatile uint32_t interrupt0OverRunStat = 0;
volatile uint32_t interrupt0RxTimeoutStat = 0;
volatile uint32_t interrupt1RxStat = 0;
volatile uint32_t interrupt1OverRunStat = 0;
volatile uint32_t interrupt1RxTimeoutStat = 0;
uint8_t sendBuffer[SSP_BUFSIZE];
/****************************************************************************************
*SSP1_IRQHandler - SSP1 interrupt handler
****************************************************************************************/
void SSP1_IRQHandler(void)
{
uint32_t regValue;
regValue = LPC_SSP1->MIS;
if ( regValue & SSPMIS_RORMIS ) /* Receive overrun interrupt */
{
interrupt1OverRunStat++;
LPC_SSP1->ICR = SSPICR_RORIC; /* clear interrupt */
}
if ( regValue & SSPMIS_RTMIS ) /* Receive timeout interrupt */
{
interrupt1RxTimeoutStat++;
LPC_SSP1->ICR = SSPICR_RTIC; /* clear interrupt */
}
/* please be aware that, in main and ISR, CurrentRxIndex and CurrentTxIndex
are shared as global variables. It may create some race condition that main
and ISR manipulate these variables at the same time. SSPSR_BSY checking (polling)
in both main and ISR could prevent this kind of race condition */
if ( regValue & SSPMIS_RXMIS ) /* Rx at least half full */
{
interrupt1RxStat++; /* receive until it's empty */
}
return;
}
/****************************************************************************************
* SSP1Init - Initialize SSP1 module
****************************************************************************************/
void SSP1Init()
{
// Enable SSP1
LPC_SC->PCONP |= (1 << SSP1_PCONP_ENABLE);
// Clock selection for SSP1
LPC_SC->PCLKSEL0 |= (3<<20);
/* PIN select P0.6 - SSP1 SSEL1, P0.7 - SSP1 SCK1
P0.8 - SSP1 MISO1, P0.9 - SSP1 MOSI1 */
LPC_PINCON->PINSEL0 &= ~((0x3<<12)|(0x3<<14)|(0x3<<16)|(0x3<<18));
LPC_PINCON->PINSEL0 |= ((0x2<<12)|(0x2<<14)|(0x2<<16)|(0x2<<18));
LPC_PINCON->PINSEL0 &= ~(3<<12); //P0.6 as gpio
LPC_GPIO0->FIODIR |= (1<<6); // SSP0 P0.6 defined as Outputs
// DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 15
LPC_SSP1->CR0 = 0x0707;
// SSP1 CPSR clock pre-scale register, master mode, minimum divisor is 0x02
LPC_SSP1->CPSR = 0x2;
/* Enable the SSP Interrupt */
NVIC_EnableIRQ(SSP1_IRQn);
/* Master mode */
LPC_SSP1->CR1 &= ~(SSPCR1_MS);
/* SSP Enable */
LPC_SSP1->CR1 = SSPCR1_SSE;
LPC_SSP1->IMSC = SSPIMSC_RORIM | SSPIMSC_RTIM;
}
/****************************************************************************************
* ssp1Send - send data over SSP1
****************************************************************************************/
uint8_t ssp1Send(uint8_t *buf, uint32_t length)
{
uint32_t i=0;
uint8_t Dummy = 0;
for( i = 0 ; i < length ; i++ )
{
/* Move on only if NOT busy and TX FIFO not full. */
while((LPC_SSP1->SR & (SSP_STAT_TNF|SSP_STAT_BSY)) != SSP_STAT_TNF);
LPC_SSP1->DR = *buf;
buf++;
while((LPC_SSP1->SR & (SSP_STAT_BSY|SSP_STAT_RNE)) != SSP_STAT_RNE);
/* Whenever a byte is written, MISO FIFO counter increments, Clear FIFO
on MISO. Otherwise, when SSP1Receive() is called, previous data byte
is left in the FIFO. */
Dummy = LPC_SSP1->DR;
}
return Dummy;
}
/****************************************************************************************
* ssp1Transfer - Transmit and receive byte on SSP1
****************************************************************************************/
uint8_t ssp1Transfer(uint8_t dataByte)
{
uint8_t data=0;
LPC_SSP1->DR = dataByte;
while(LPC_SSP1->SR & (1<<4));
data = LPC_SSP1->DR;
return data;
}
/*
uint8_t ssp1Transfer(uint8_t dataByte)
{
uint8_t dummy=0;
sendBuffer[0] = dataByte;
dummy = ssp1Send((uint8_t *)sendBuffer, 1 );
return dummy;
}
*/
| [
"noreply@github.com"
] | vatsalm93.noreply@github.com |
9ff5606f9326687341e4e890eb51de0b5947c1b3 | eaa93654fd35647c6ae2b9e499aea67be24ace35 | /include/pulsar/bfsar/bfsar.h | 3ffcb0f3d95fcef0396f1a98a56e4281b2262f44 | [
"MIT"
] | permissive | p-sam/switch-libpulsar | 76ef981b71096ee83304ee64cc2f50d7b214d33c | 3d3a057f4aa2578cdb89cab3596967c47de73b73 | refs/heads/develop | 2023-06-27T02:36:38.864291 | 2021-08-01T11:30:12 | 2021-08-01T11:34:26 | 330,776,117 | 9 | 1 | MIT | 2021-08-01T11:34:27 | 2021-01-18T20:13:25 | C | UTF-8 | C | false | false | 1,319 | h | /**
* @file
* @brief Sound archive init
*/
#pragma once
#include <pulsar/archive/archive.h>
#include <pulsar/bfsar/bfsar_internal.h>
/// Sound archive method categories
typedef enum {
PLSR_BFSARCategoryType_Init = 0,
PLSR_BFSARCategoryType_IdList,
PLSR_BFSARCategoryType_String,
PLSR_BFSARCategoryType_Sound,
PLSR_BFSARCategoryType_WaveArchive,
PLSR_BFSARCategoryType_Group,
PLSR_BFSARCategoryType_File,
} PLSR_BFSARCategoryType;
/// String tree header information
typedef struct {
u32 rootNodeIndex;
u32 nodeCount;
} PLSR_BFSARStringTreeInfo;
/// String tree (patricia trie)
typedef struct {
u32 offset; ///< Section start offset in sound archive
PLSR_BFSARStringTreeInfo info; ///< Cached tree information
} PLSR_BFSARStringTree;
/// Sound archive file
typedef struct {
PLSR_Archive ar;
PLSR_ArchiveHeaderInfo headerInfo;
PLSR_ArchiveSection strgSection;
PLSR_ArchiveSection infoSection;
PLSR_ArchiveSection fileSection;
PLSR_ArchiveTable stringTable;
PLSR_BFSARStringTree stringTree;
PLSR_ArchiveTable soundTable;
PLSR_ArchiveTable waveArchiveTable;
PLSR_ArchiveTable groupTable;
PLSR_ArchiveTable fileTable;
} PLSR_BFSAR;
/// @copydoc plsrArchiveOpen
PLSR_RC plsrBFSAROpen(const char* path, PLSR_BFSAR* out);
/// @copydoc plsrArchiveClose
void plsrBFSARClose(PLSR_BFSAR* bfsar);
| [
"p-sam@d3vs.net"
] | p-sam@d3vs.net |
9a1e3637050bc1699b29db34ed50401a50827d64 | fbe68d84e97262d6d26dd65c704a7b50af2b3943 | /third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdePkg/Library/PeiServicesLib/PeiServicesLib.c | 75436feb8a470f13fc8728e9cba79cb4ea060a07 | [
"GPL-2.0-only",
"LicenseRef-scancode-unknown-license-reference",
"CDDL-1.0",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"GPL-2.0-or-later",
"MPL-1.0",
"LicenseRef-scancode-generic-exception",
"Apache-2.0",
"OpenSSL",
"MIT",
"BSD-2-Clause"
] | permissive | thalium/icebox | c4e6573f2b4f0973b6c7bb0bf068fe9e795fdcfb | 6f78952d58da52ea4f0e55b2ab297f28e80c1160 | refs/heads/master | 2022-08-14T00:19:36.984579 | 2022-02-22T13:10:31 | 2022-02-22T13:10:31 | 190,019,914 | 585 | 109 | MIT | 2022-01-13T20:58:15 | 2019-06-03T14:18:12 | C++ | UTF-8 | C | false | false | 28,573 | c | /** @file
Implementation for PEI Services Library.
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiPei.h>
#include <Ppi/FirmwareVolumeInfo.h>
#include <Ppi/FirmwareVolumeInfo2.h>
#include <Guid/FirmwareFileSystem2.h>
#include <Library/PeiServicesLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
/**
This service enables a given PEIM to register an interface into the PEI Foundation.
@param PpiList A pointer to the list of interfaces that the caller shall install.
@retval EFI_SUCCESS The interface was successfully installed.
@retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
@retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
@retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
**/
EFI_STATUS
EFIAPI
PeiServicesInstallPpi (
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->InstallPpi (PeiServices, PpiList);
}
/**
This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
@param OldPpi The pointer to the old PEI PPI Descriptors.
@param NewPpi The pointer to the new PEI PPI Descriptors.
@retval EFI_SUCCESS The interface was successfully installed.
@retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
@retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
@retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
@retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
installed.
**/
EFI_STATUS
EFIAPI
PeiServicesReInstallPpi (
IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);
}
/**
This service enables PEIMs to discover a given instance of an interface.
@param Guid A pointer to the GUID whose corresponding interface needs to be
found.
@param Instance The N-th instance of the interface that is required.
@param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
@param Ppi A pointer to the instance of the interface.
@retval EFI_SUCCESS The interface was successfully returned.
@retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
**/
EFI_STATUS
EFIAPI
PeiServicesLocatePpi (
IN CONST EFI_GUID *Guid,
IN UINTN Instance,
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
IN OUT VOID **Ppi
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);
}
/**
This service enables PEIMs to register a given service to be invoked when another service is
installed or reinstalled.
@param NotifyList A pointer to the list of notification interfaces
that the caller shall install.
@retval EFI_SUCCESS The interface was successfully installed.
@retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
@retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do
not have the EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
bit set in the Flags field.
@retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
**/
EFI_STATUS
EFIAPI
PeiServicesNotifyPpi (
IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);
}
/**
This service enables PEIMs to ascertain the present value of the boot mode.
@param BootMode A pointer to contain the value of the boot mode.
@retval EFI_SUCCESS The boot mode was returned successfully.
@retval EFI_INVALID_PARAMETER BootMode is NULL.
**/
EFI_STATUS
EFIAPI
PeiServicesGetBootMode (
OUT EFI_BOOT_MODE *BootMode
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->GetBootMode (PeiServices, BootMode);
}
/**
This service enables PEIMs to update the boot mode variable.
@param BootMode The value of the boot mode to set.
@retval EFI_SUCCESS The value was successfully updated
**/
EFI_STATUS
EFIAPI
PeiServicesSetBootMode (
IN EFI_BOOT_MODE BootMode
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->SetBootMode (PeiServices, BootMode);
}
/**
This service enables a PEIM to ascertain the address of the list of HOBs in memory.
@param HobList A pointer to the list of HOBs that the PEI Foundation
will initialize.
@retval EFI_SUCCESS The list was successfully returned.
@retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
**/
EFI_STATUS
EFIAPI
PeiServicesGetHobList (
OUT VOID **HobList
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->GetHobList (PeiServices, HobList);
}
/**
This service enables PEIMs to create various types of HOBs.
@param Type The type of HOB to be installed.
@param Length The length of the HOB to be added.
@param Hob The address of a pointer that will contain the
HOB header.
@retval EFI_SUCCESS The HOB was successfully created.
@retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
**/
EFI_STATUS
EFIAPI
PeiServicesCreateHob (
IN UINT16 Type,
IN UINT16 Length,
OUT VOID **Hob
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);
}
/**
This service enables PEIMs to discover additional firmware volumes.
@param Instance This instance of the firmware volume to find. The
value 0 is the Boot Firmware Volume (BFV).
@param VolumeHandle Handle of the firmware volume header of the volume
to return.
@retval EFI_SUCCESS The volume was found.
@retval EFI_NOT_FOUND The volume was not found.
@retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsFindNextVolume (
IN UINTN Instance,
IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);
}
/**
This service enables PEIMs to discover additional firmware files.
@param SearchType A filter to find files only of this type.
@param VolumeHandle The pointer to the firmware volume header of the
volume to search. This parameter must point to a
valid FFS volume.
@param FileHandle Handle of the current file from which to begin searching.
@retval EFI_SUCCESS The file was found.
@retval EFI_NOT_FOUND The file was not found.
@retval EFI_NOT_FOUND The header checksum was not zero.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsFindNextFile (
IN EFI_FV_FILETYPE SearchType,
IN EFI_PEI_FV_HANDLE VolumeHandle,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, VolumeHandle, FileHandle);
}
/**
This service enables PEIMs to discover sections of a given type within a valid FFS file.
@param SectionType The value of the section type to find.
@param FileHandle A pointer to the file header that contains the set
of sections to be searched.
@param SectionData A pointer to the discovered section, if successful.
@retval EFI_SUCCESS The section was found.
@retval EFI_NOT_FOUND The section was not found.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsFindSectionData (
IN EFI_SECTION_TYPE SectionType,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT VOID **SectionData
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FileHandle, SectionData);
}
/**
This service enables PEIMs to discover sections of a given instance and type within a valid FFS file.
@param SectionType The value of the section type to find.
@param SectionInstance Section instance to find.
@param FileHandle A pointer to the file header that contains the set
of sections to be searched.
@param SectionData A pointer to the discovered section, if successful.
@param AuthenticationStatus A pointer to the authentication status for this section.
@retval EFI_SUCCESS The section was found.
@retval EFI_NOT_FOUND The section was not found.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsFindSectionData3 (
IN EFI_SECTION_TYPE SectionType,
IN UINTN SectionInstance,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT VOID **SectionData,
OUT UINT32 *AuthenticationStatus
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->FindSectionData3 (PeiServices, SectionType, SectionInstance, FileHandle, SectionData, AuthenticationStatus);
}
/**
This service enables PEIMs to register the permanent memory configuration
that has been initialized with the PEI Foundation.
@param MemoryBegin The value of a region of installed memory.
@param MemoryLength The corresponding length of a region of installed memory.
@retval EFI_SUCCESS The region was successfully installed in a HOB.
@retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
@retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
**/
EFI_STATUS
EFIAPI
PeiServicesInstallPeiMemory (
IN EFI_PHYSICAL_ADDRESS MemoryBegin,
IN UINT64 MemoryLength
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);
}
/**
This service enables PEIMs to allocate memory after the permanent memory has been
installed by a PEIM.
@param MemoryType Type of memory to allocate.
@param Pages The number of pages to allocate.
@param Memory Pointer of memory allocated.
@retval EFI_SUCCESS The memory range was successfully allocated.
@retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
@retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
@retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
**/
EFI_STATUS
EFIAPI
PeiServicesAllocatePages (
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->AllocatePages (PeiServices, MemoryType, Pages, Memory);
}
/**
This service allocates memory from the Hand-Off Block (HOB) heap.
@param Size The number of bytes to allocate from the pool.
@param Buffer If the call succeeds, a pointer to a pointer to
the allocate buffer; otherwise, undefined.
@retval EFI_SUCCESS The allocation was successful
@retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
**/
EFI_STATUS
EFIAPI
PeiServicesAllocatePool (
IN UINTN Size,
OUT VOID **Buffer
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->AllocatePool (PeiServices, Size, Buffer);
}
/**
Resets the entire platform.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
**/
EFI_STATUS
EFIAPI
PeiServicesResetSystem (
VOID
)
{
CONST EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer ();
return (*PeiServices)->ResetSystem (PeiServices);
}
/**
This service is a wrapper for the PEI Service RegisterForShadow(), except the
pointer to the PEI Services Table has been removed. See the Platform
Initialization Pre-EFI Initialization Core Interface Specification for details.
@param FileHandle PEIM's file handle. Must be the currently
executing PEIM.
@retval EFI_SUCCESS The PEIM was successfully registered for
shadowing.
@retval EFI_ALREADY_STARTED The PEIM was previously
registered for shadowing.
@retval EFI_NOT_FOUND The FileHandle does not refer to a
valid file handle.
**/
EFI_STATUS
EFIAPI
PeiServicesRegisterForShadow (
IN EFI_PEI_FILE_HANDLE FileHandle
)
{
return (*GetPeiServicesTablePointer())->RegisterForShadow (FileHandle);
}
/**
This service is a wrapper for the PEI Service FfsGetFileInfo(), except the pointer to the PEI Services
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
Specification for details.
@param FileHandle The handle of the file.
@param FileInfo Upon exit, points to the file's
information.
@retval EFI_SUCCESS File information returned.
@retval EFI_INVALID_PARAMETER If FileHandle does not
represent a valid file.
@retval EFI_INVALID_PARAMETER FileInfo is NULL.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsGetFileInfo (
IN CONST EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_FV_FILE_INFO *FileInfo
)
{
return (*GetPeiServicesTablePointer())->FfsGetFileInfo (FileHandle, FileInfo);
}
/**
This service is a wrapper for the PEI Service FfsGetFileInfo2(), except the pointer to the PEI Services
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
Specification for details.
@param FileHandle The handle of the file.
@param FileInfo Upon exit, points to the file's
information.
@retval EFI_SUCCESS File information returned.
@retval EFI_INVALID_PARAMETER If FileHandle does not
represent a valid file.
@retval EFI_INVALID_PARAMETER FileInfo is NULL.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsGetFileInfo2 (
IN CONST EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_FV_FILE_INFO2 *FileInfo
)
{
return (*GetPeiServicesTablePointer())->FfsGetFileInfo2 (FileHandle, FileInfo);
}
/**
This service is a wrapper for the PEI Service FfsFindByName(), except the pointer to the PEI Services
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
Specification for details.
@param FileName A pointer to the name of the file to
find within the firmware volume.
@param VolumeHandle The firmware volume to search FileHandle
Upon exit, points to the found file's
handle or NULL if it could not be found.
@param FileHandle The pointer to found file handle
@retval EFI_SUCCESS File was found.
@retval EFI_NOT_FOUND File was not found.
@retval EFI_INVALID_PARAMETER VolumeHandle or FileHandle or
FileName was NULL.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsFindFileByName (
IN CONST EFI_GUID *FileName,
IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
return (*GetPeiServicesTablePointer())->FfsFindFileByName (FileName, VolumeHandle, FileHandle);
}
/**
This service is a wrapper for the PEI Service FfsGetVolumeInfo(), except the pointer to the PEI Services
Table has been removed. See the Platform Initialization Pre-EFI Initialization Core Interface
Specification for details.
@param VolumeHandle Handle of the volume.
@param VolumeInfo Upon exit, points to the volume's
information.
@retval EFI_SUCCESS File information returned.
@retval EFI_INVALID_PARAMETER If FileHandle does not
represent a valid file.
@retval EFI_INVALID_PARAMETER If FileInfo is NULL.
**/
EFI_STATUS
EFIAPI
PeiServicesFfsGetVolumeInfo (
IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
)
{
return (*GetPeiServicesTablePointer())->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);
}
/**
Install a EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance so the PEI Core will be notified about a new firmware volume.
This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI using
the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI instance.
If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI, then ASSERT().
If the EFI_PEI_FIRMWARE_VOLUME_INFO(2)_PPI can not be installed, then ASSERT().
@param InstallFvInfoPpi Install FvInfo Ppi if it is TRUE. Otherwise, install FvInfo2 Ppi.
@param FvFormat Unique identifier of the format of the memory-mapped
firmware volume. This parameter is optional and
may be NULL. If NULL is specified, the
EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
@param FvInfo Points to a buffer which allows the
EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
The format of this buffer is specific to the FvFormat.
For memory-mapped firmware volumes, this typically
points to the first byte of the firmware volume.
@param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
firmware volumes, this is typically the size of
the firmware volume.
@param ParentFvName If the new firmware volume originated from a file
in a different firmware volume, then this parameter
specifies the GUID name of the originating firmware
volume. Otherwise, this parameter must be NULL.
@param ParentFileName If the new firmware volume originated from a file
in a different firmware volume, then this parameter
specifies the GUID file name of the originating
firmware file. Otherwise, this parameter must be NULL.
@param AuthenticationStatus Authentication Status, it will be ignored if InstallFvInfoPpi is TRUE.
**/
VOID
EFIAPI
InternalPeiServicesInstallFvInfoPpi (
IN BOOLEAN InstallFvInfoPpi,
IN CONST EFI_GUID *FvFormat, OPTIONAL
IN CONST VOID *FvInfo,
IN UINT32 FvInfoSize,
IN CONST EFI_GUID *ParentFvName, OPTIONAL
IN CONST EFI_GUID *ParentFileName, OPTIONAL
IN UINT32 AuthenticationStatus
)
{
EFI_STATUS Status;
EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi;
EFI_PEI_PPI_DESCRIPTOR *FvInfoPpiDescriptor;
EFI_GUID *ParentFvNameValue;
EFI_GUID *ParentFileNameValue;
EFI_GUID *PpiGuid;
ParentFvNameValue = NULL;
ParentFileNameValue = NULL;
if (InstallFvInfoPpi) {
//
// To install FvInfo Ppi.
//
FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));
ASSERT (FvInfoPpi != NULL);
PpiGuid = &gEfiPeiFirmwareVolumeInfoPpiGuid;
} else {
//
// To install FvInfo2 Ppi.
//
FvInfoPpi = AllocateZeroPool (sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));
ASSERT (FvInfoPpi != NULL);
((EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI *) FvInfoPpi)->AuthenticationStatus = AuthenticationStatus;
PpiGuid = &gEfiPeiFirmwareVolumeInfo2PpiGuid;
}
if (FvFormat != NULL) {
CopyGuid (&FvInfoPpi->FvFormat, FvFormat);
} else {
CopyGuid (&FvInfoPpi->FvFormat, &gEfiFirmwareFileSystem2Guid);
}
FvInfoPpi->FvInfo = (VOID *) FvInfo;
FvInfoPpi->FvInfoSize = FvInfoSize;
if (ParentFvName != NULL) {
ParentFvNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFvName);
ASSERT (ParentFvNameValue != NULL);
FvInfoPpi->ParentFvName = ParentFvNameValue;
}
if (ParentFileName != NULL) {
ParentFileNameValue = AllocateCopyPool (sizeof (EFI_GUID), ParentFileName);
ASSERT (ParentFileNameValue != NULL);
FvInfoPpi->ParentFileName = ParentFileNameValue;
}
FvInfoPpiDescriptor = AllocatePool (sizeof (EFI_PEI_PPI_DESCRIPTOR));
ASSERT (FvInfoPpiDescriptor != NULL);
FvInfoPpiDescriptor->Guid = PpiGuid;
FvInfoPpiDescriptor->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
FvInfoPpiDescriptor->Ppi = (VOID *) FvInfoPpi;
Status = PeiServicesInstallPpi (FvInfoPpiDescriptor);
ASSERT_EFI_ERROR (Status);
}
/**
Install a EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance so the PEI Core will be notified about a new firmware volume.
This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO_PPI using
the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI instance.
If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO_PPI, then ASSERT().
If the EFI_PEI_FIRMWARE_VOLUME_INFO_PPI can not be installed, then ASSERT().
@param FvFormat Unique identifier of the format of the memory-mapped
firmware volume. This parameter is optional and
may be NULL. If NULL is specified, the
EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
@param FvInfo Points to a buffer which allows the
EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
The format of this buffer is specific to the FvFormat.
For memory-mapped firmware volumes, this typically
points to the first byte of the firmware volume.
@param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
firmware volumes, this is typically the size of
the firmware volume.
@param ParentFvName If the new firmware volume originated from a file
in a different firmware volume, then this parameter
specifies the GUID name of the originating firmware
volume. Otherwise, this parameter must be NULL.
@param ParentFileName If the new firmware volume originated from a file
in a different firmware volume, then this parameter
specifies the GUID file name of the originating
firmware file. Otherwise, this parameter must be NULL.
**/
VOID
EFIAPI
PeiServicesInstallFvInfoPpi (
IN CONST EFI_GUID *FvFormat, OPTIONAL
IN CONST VOID *FvInfo,
IN UINT32 FvInfoSize,
IN CONST EFI_GUID *ParentFvName, OPTIONAL
IN CONST EFI_GUID *ParentFileName OPTIONAL
)
{
InternalPeiServicesInstallFvInfoPpi (TRUE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, 0);
}
/**
Install a EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance so the PEI Core will be notified about a new firmware volume.
This function allocates, initializes, and installs a new EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI using
the parameters passed in to initialize the fields of the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI instance.
If the resources can not be allocated for EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI, then ASSERT().
If the EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI can not be installed, then ASSERT().
@param FvFormat Unique identifier of the format of the memory-mapped
firmware volume. This parameter is optional and
may be NULL. If NULL is specified, the
EFI_FIRMWARE_FILE_SYSTEM2_GUID format is assumed.
@param FvInfo Points to a buffer which allows the
EFI_PEI_FIRMWARE_VOLUME_PPI to process the volume.
The format of this buffer is specific to the FvFormat.
For memory-mapped firmware volumes, this typically
points to the first byte of the firmware volume.
@param FvInfoSize The size, in bytes, of FvInfo. For memory-mapped
firmware volumes, this is typically the size of
the firmware volume.
@param ParentFvName If the new firmware volume originated from a file
in a different firmware volume, then this parameter
specifies the GUID name of the originating firmware
volume. Otherwise, this parameter must be NULL.
@param ParentFileName If the new firmware volume originated from a file
in a different firmware volume, then this parameter
specifies the GUID file name of the originating
firmware file. Otherwise, this parameter must be NULL.
@param AuthenticationStatus Authentication Status
**/
VOID
EFIAPI
PeiServicesInstallFvInfo2Ppi (
IN CONST EFI_GUID *FvFormat, OPTIONAL
IN CONST VOID *FvInfo,
IN UINT32 FvInfoSize,
IN CONST EFI_GUID *ParentFvName, OPTIONAL
IN CONST EFI_GUID *ParentFileName, OPTIONAL
IN UINT32 AuthenticationStatus
)
{
InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, ParentFvName, ParentFileName, AuthenticationStatus);
}
| [
"benoit.amiaux@gmail.com"
] | benoit.amiaux@gmail.com |
50da78c5079593899c24f897d0d50aeebe978e33 | 619be190edc46e1f7ca2e0f056149789183c496f | /src/c/green_line_update_callback.c | 1796cbbdbf7e7ae611c88b23a2ce321b4d3c4201 | [] | no_license | DHKaplan/Girl-Scouts | a06539005c27d8a73bddff111414ec22d0efe41c | 9e3ce86de273fb4560cb96911a8a72f0839990a3 | refs/heads/master | 2021-01-17T13:10:46.332034 | 2017-06-13T20:03:49 | 2017-06-13T20:03:49 | 63,906,861 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 443 | c | #include <pebble.h>
#include "green_line_update_callback.h"
#include "Girl-Scouts.h"
void red_line_layer_update_callback(Layer *RedLineLayer, GContext* ctx) {
#if PBL_COLOR
graphics_context_set_fill_color(ctx, GColorMalachite);
#else
//B&W
graphics_context_set_fill_color(ctx, GColorWhite);
#endif
graphics_fill_rect(ctx, layer_get_bounds(RedLineLayer), 0, GCornerNone);
} | [
"wa1oui.ham@gmail.com"
] | wa1oui.ham@gmail.com |
569fe1146deb76ea3c61b27eb1157e413ac16a17 | c76ba19393762c4dc9093b5fdf16634706ab40a9 | /srcs_nm/handle_32.c | 0b6c9f6dd77367f44d126d66c4247a48654903eb | [] | no_license | rkirszba/nm_otool | b0eac1216e715048fd57e3b965582838962ab7a3 | 2cddeb141a153435b769dded3c2bd49957b0c927 | refs/heads/master | 2023-02-23T14:31:32.546467 | 2021-01-29T14:18:55 | 2021-01-29T14:18:55 | 328,996,032 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 4,472 | c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* handle_32.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rkirszba <rkirszba@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/16 17:27:57 by rkirszba #+# #+# */
/* Updated: 2021/01/27 11:36:17 by rkirszba ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_nm.h"
static char *symbol_get_name_32(t_file_data *file, struct nlist *sym)
{
char *name;
uint32_t n_strx;
uint32_t n;
n_strx = endian_wrap_u32(sym->n_un.n_strx, file->endian);
if (n_strx == 0)
return (ft_strdup(""));
if (n_strx > file->str_size)
return (ft_strdup(BAD_STR_INDEX));
name = file->sym_str + n_strx;
if (is_inside_file_abs(file->content, file->size, (void*)name) == FALSE)
return (ft_strdup(BAD_STR_INDEX));
n = distance_to_eof(file->content, file->size, (void*)name);
return (ft_strndup(name, n - 1));
}
static int8_t symbol_get_32(t_file_data *file, struct nlist *sym)
{
t_symbol_data *new_symbol;
int8_t ret;
if (!(new_symbol = (t_symbol_data*)malloc(sizeof(*new_symbol))))
return (print_malloc_error());
ft_bzero(new_symbol, sizeof(*new_symbol));
if (!(new_symbol->name = symbol_get_name_32(file, sym)))
{
free(new_symbol);
return (print_malloc_error());
}
new_symbol->value = endian_wrap_u32(sym->n_value, file->endian);
new_symbol->debug = sym->n_type & N_STAB;
new_symbol->type = sym->n_type & N_TYPE;
new_symbol->ext = sym->n_type & N_EXT;
symbol_get_section(file, new_symbol, sym->n_sect);
ret = symbol_to_tree(&file->symbols, new_symbol);
if (ret == MALLOC_ERROR)
free_symbol_data(new_symbol);
return (ret ? ERROR : SUCCESS);
}
static int8_t symbols_get_32(t_file_data *file)
{
struct symtab_command *sym_cmd;
struct nlist *sym_tab;
uint32_t i;
uint32_t nsyms;
uint32_t symoff;
if (is_inside_file_rel(file->size, file->off_symcmd,
sizeof(*sym_cmd)) == FALSE)
return (print_corrupted_file_error(file));
sym_cmd = (struct symtab_command*)(file->content + file->off_symcmd);
nsyms = endian_wrap_u32(sym_cmd->nsyms, file->endian);
symoff = endian_wrap_u32(sym_cmd->symoff, file->endian) + file->off_header;
if (is_inside_file_rel(file->size, symoff,
sizeof(*sym_tab) * nsyms) == FALSE)
return (print_corrupted_file_error(file));
sym_tab = (struct nlist*)(file->content + symoff);
file->sym_str = (char*)file->content
+ endian_wrap_u32(sym_cmd->stroff, file->endian) + file->off_header;
file->str_size = endian_wrap_u32(sym_cmd->strsize, file->endian);
i = -1;
while (++i < nsyms)
if (symbol_get_32(file, &sym_tab[i]))
return (ERROR);
return (SUCCESS);
}
static int8_t load_commands_parse_32(t_file_data *file, uint32_t ncmds)
{
uint32_t i;
int32_t offset;
struct load_command *lc;
uint32_t cmd;
i = 0;
offset = file->off_header + sizeof(struct mach_header);
while (i < ncmds)
{
if (is_inside_file_rel(file->size, offset, sizeof(*lc)) == FALSE)
return (print_corrupted_file_error(file));
lc = (struct load_command*)(file->content + offset);
cmd = endian_wrap_u32(lc->cmd, file->endian);
if (cmd == LC_SYMTAB)
file->off_symcmd = offset;
if (cmd == LC_SEGMENT)
if (segment_parse_32(file, offset) == ERROR)
return (ERROR);
offset += endian_wrap_u32(lc->cmdsize, file->endian);
i++;
}
return (file->off_symcmd ? SUCCESS : print_corrupted_file_error(file));
}
int8_t handle_mh_32(t_file_data *file)
{
struct mach_header *header;
int8_t ret;
file->bits = bits32;
if (is_inside_file_rel(file->size, file->off_header,
sizeof(*header)) == FALSE)
return (print_corrupted_file_error(file));
header = (struct mach_header*)(file->content + file->off_header);
ret = load_commands_parse_32(file,
endian_wrap_u32(header->ncmds, file->endian));
if (ret == SUCCESS)
ret = symbols_get_32(file);
if (ret == SUCCESS)
symbols_print(file);
ft_btree_free(file->symbols, &free_symbol_data);
return (ret);
}
| [
"rkirszba@student.42.fr"
] | rkirszba@student.42.fr |
9a092642b63e9046800fb02e3c9d14da9a2fb8f5 | 06b48e4a5a94d023d43deee4fde0da908ef556a8 | /linklist.h | 292e0788ed32b6b0275f8ec4d0167179abf59576 | [] | no_license | fangpeng0912/linklist_practice | 812374ad2f7d23204719a75477493b182282d0e7 | 86405a493020366d01ea6f77cbb64d7ad657cc76 | refs/heads/master | 2020-12-09T22:15:34.542887 | 2020-02-08T18:07:36 | 2020-02-08T18:07:36 | 233,430,993 | 0 | 0 | null | null | null | null | GB18030 | C | false | false | 572 | h | #ifndef _LINKLIST_H_
#define _LINKLIST_H_
#include <stdlib.h>
//链表元素类型定义
typedef int ElemType;
//链表结构定义
typedef struct Node{
ElemType data;
struct Node *next;
}Node, *LinkList;
#define OK 0
#define ERROR -1
//链表元素的插入
int listInsert(LinkList l, int i, ElemType e);
//链表元素的删除
int listDelete(LinkList l, int i, ElemType *pe);
//链表元素的读取
int listRead(LinkList l, int i, ElemType *pe);
//链表元素的查找
int listSearch(LinkList l, ElemType e);
#endif
| [
"1228779234@qq.com"
] | 1228779234@qq.com |
8a0e8f2060574e4f1d24d6b618ee34c31152e3ab | 5c255f911786e984286b1f7a4e6091a68419d049 | /vulnerable_code/cddd5bd6-1165-47a2-9b0b-a504b219ea61.c | 238361d8d46b7cbfba207a6753c44078616bffdc | [] | no_license | nmharmon8/Deep-Buffer-Overflow-Detection | 70fe02c8dc75d12e91f5bc4468cf260e490af1a4 | e0c86210c86afb07c8d4abcc957c7f1b252b4eb2 | refs/heads/master | 2021-09-11T19:09:59.944740 | 2018-04-06T16:26:34 | 2018-04-06T16:26:34 | 125,521,331 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 570 | c | #include <string.h>
#include <stdio.h>
int main() {
float i;
float j;
float k;
float l;
i = 6;
j = 9;
//variables
//random
/* START VULNERABILITY */
int a;
int b[30];
int c[56];
a = 0;
do {
a++;
/* START BUFFER SET */
*((int *)c + ( a - 1 )) = *((int *)b + ( a - 1 ));
/* END BUFFER SET */
//random
} while(( a - 1 ) < strlen(b));
/* END VULNERABILITY */
k = 3;
l = 6*j*k/9;
printf("vulnerabbbity");
printf("%f\n",l);
return 0;
}
| [
"nharmon8@gmail.com"
] | nharmon8@gmail.com |
d186a81e3139768f63fb41165b353bda0a3a45ec | 91bdefa2dad13a24eb3362cb5bf06f7a577e1c87 | /CONFIG/inc/config.h | 239ffff838ab572c56e674bf73e711926a8f160e | [] | no_license | JustYouNeed/VectorFly-F4 | d35dd5c0a74f2e6ec38e52e4c42d81d455e8f40b | 53b051f0807a287e771f8b6322d635611abcdab2 | refs/heads/master | 2020-03-27T06:04:00.974262 | 2018-08-25T07:26:44 | 2018-08-25T07:26:44 | 146,075,410 | 1 | 1 | null | null | null | null | GB18030 | C | false | false | 1,116 | h | /**
*******************************************************************************************************
* File Name: config.h
* Author: Vector
* Version: V1.0.0
* Date: 2018-8-23
* Brief: Vector配置文件
*******************************************************************************************************
* History
* Author: Vector
* Date: 2018-8-23
* Mod: 建立文件
*
*******************************************************************************************************
*/
# ifndef __CONFIG_H
# define __CONFIG_H
/* 串口部分配置 */
# define UART_LINK_COM USART1
# define UART_LINK_PORT GPIOB
# define UART_LINK_RX_PIN GPIO_Pin_6
# define UART_LINK_TX_PIN GPIO_Pin_7
# define UART_LINK_BAUDRATE 961200
/* MPU9250引脚配置部分 */
# define MPU_SDA_PORT GPIOB
# define MPU_SDA_PIN GPIO_Pin_8
# define MPU_SCL_PORT GPIOB
# define MPU_SCL_PIN GPIO_Pin_9
# define MPU_INT_PORT GPIOB
# define MPU_INT_PIN GPIO_Pin_5
# endif
/******************************************** END OF FILE *******************************************/
| [
"1324654767@qq.com"
] | 1324654767@qq.com |
be726ff9f5c42717f4e260a4e57549827157d7af | a364f5e25e4ec3563c2a6e366069488786927948 | /sys/kern/subr_autoconf.c | d19b59a8c5aaa5523aa991e3802756c16b015764 | [] | no_license | noud/mouse-bsd | b044db5ba4085794b94ea729eb4148e1c86d73b5 | a16ee9b253dbd25c931216ef9be36611fb847411 | refs/heads/main | 2023-02-24T06:22:20.517329 | 2020-08-25T20:21:40 | 2020-08-25T20:21:40 | 334,500,331 | 1 | 0 | null | null | null | null | UTF-8 | C | false | false | 18,831 | c | /* $NetBSD: subr_autoconf.c,v 1.49 2000/02/01 04:01:19 danw Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratories.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL)
*
* @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/proc.h>
#include <machine/limits.h>
/*
* Autoconfiguration subroutines.
*/
/*
* ioconf.c exports exactly two names: cfdata and cfroots. All system
* devices and drivers are found via these tables.
*/
extern struct cfdata cfdata[];
extern short cfroots[];
#define ROOT ((struct device *)NULL)
struct matchinfo {
cfmatch_t fn;
struct device *parent;
void *aux;
struct cfdata *match;
int pri;
};
static char *number __P((char *, int));
static void mapply __P((struct matchinfo *, struct cfdata *));
struct deferred_config {
TAILQ_ENTRY(deferred_config) dc_queue;
struct device *dc_dev;
void (*dc_func) __P((struct device *));
};
TAILQ_HEAD(deferred_config_head, deferred_config);
struct deferred_config_head deferred_config_queue;
struct deferred_config_head interrupt_config_queue;
static void config_process_deferred __P((struct deferred_config_head *,
struct device *));
struct devicelist alldevs; /* list of all devices */
struct evcntlist allevents; /* list of all event counters */
__volatile int config_pending; /* semaphore for mountroot */
/*
* Configure the system's hardware.
*/
void
configure()
{
TAILQ_INIT(&deferred_config_queue);
TAILQ_INIT(&interrupt_config_queue);
TAILQ_INIT(&alldevs);
TAILQ_INIT(&allevents);
/*
* Do the machine-dependent portion of autoconfiguration. This
* sets the configuration machinery here in motion by "finding"
* the root bus. When this function returns, we expect interrupts
* to be enabled.
*/
cpu_configure();
/*
* Now that we've found all the hardware, start the real time
* and statistics clocks.
*/
initclocks();
cold = 0; /* clocks are running, we're warm now! */
/*
* Now callback to finish configuration for devices which want
* to do this once interrupts are enabled.
*/
config_process_deferred(&interrupt_config_queue, NULL);
}
/*
* Apply the matching function and choose the best. This is used
* a few times and we want to keep the code small.
*/
static void
mapply(m, cf)
register struct matchinfo *m;
register struct cfdata *cf;
{
register int pri;
if (m->fn != NULL)
pri = (*m->fn)(m->parent, cf, m->aux);
else {
if (cf->cf_attach->ca_match == NULL) {
panic("mapply: no match function for '%s' device\n",
cf->cf_driver->cd_name);
}
pri = (*cf->cf_attach->ca_match)(m->parent, cf, m->aux);
}
if (pri > m->pri) {
m->match = cf;
m->pri = pri;
}
}
/*
* Iterate over all potential children of some device, calling the given
* function (default being the child's match function) for each one.
* Nonzero returns are matches; the highest value returned is considered
* the best match. Return the `found child' if we got a match, or NULL
* otherwise. The `aux' pointer is simply passed on through.
*
* Note that this function is designed so that it can be used to apply
* an arbitrary function to all potential children (its return value
* can be ignored).
*/
struct cfdata *
config_search(fn, parent, aux)
cfmatch_t fn;
register struct device *parent;
void *aux;
{
register struct cfdata *cf;
register short *p;
struct matchinfo m;
m.fn = fn;
m.parent = parent;
m.aux = aux;
m.match = NULL;
m.pri = 0;
for (cf = cfdata; cf->cf_driver; cf++) {
/*
* Skip cf if no longer eligible, otherwise scan through
* parents for one matching `parent', and try match function.
*/
if (cf->cf_fstate == FSTATE_FOUND)
continue;
for (p = cf->cf_parents; *p >= 0; p++)
if (parent->dv_cfdata == &cfdata[*p])
mapply(&m, cf);
}
return (m.match);
}
/*
* Find the given root device.
* This is much like config_search, but there is no parent.
*/
struct cfdata *
config_rootsearch(fn, rootname, aux)
register cfmatch_t fn;
register char *rootname;
register void *aux;
{
register struct cfdata *cf;
register short *p;
struct matchinfo m;
m.fn = fn;
m.parent = ROOT;
m.aux = aux;
m.match = NULL;
m.pri = 0;
/*
* Look at root entries for matching name. We do not bother
* with found-state here since only one root should ever be
* searched (and it must be done first).
*/
for (p = cfroots; *p >= 0; p++) {
cf = &cfdata[*p];
if (strcmp(cf->cf_driver->cd_name, rootname) == 0)
mapply(&m, cf);
}
return (m.match);
}
static char *msgs[3] = { "", " not configured\n", " unsupported\n" };
/*
* The given `aux' argument describes a device that has been found
* on the given parent, but not necessarily configured. Locate the
* configuration data for that device (using the submatch function
* provided, or using candidates' cd_match configuration driver
* functions) and attach it, and return true. If the device was
* not configured, call the given `print' function and return 0.
*/
struct device *
config_found_sm(parent, aux, print, submatch)
struct device *parent;
void *aux;
cfprint_t print;
cfmatch_t submatch;
{
struct cfdata *cf;
if ((cf = config_search(submatch, parent, aux)) != NULL)
return (config_attach(parent, cf, aux, print));
if (print)
printf(msgs[(*print)(aux, parent->dv_xname)]);
return (NULL);
}
/*
* As above, but for root devices.
*/
struct device *
config_rootfound(rootname, aux)
char *rootname;
void *aux;
{
struct cfdata *cf;
if ((cf = config_rootsearch((cfmatch_t)NULL, rootname, aux)) != NULL)
return (config_attach(ROOT, cf, aux, (cfprint_t)NULL));
printf("root device %s not configured\n", rootname);
return (NULL);
}
/* just like sprintf(buf, "%d") except that it works from the end */
static char *
number(ep, n)
register char *ep;
register int n;
{
*--ep = 0;
while (n >= 10) {
*--ep = (n % 10) + '0';
n /= 10;
}
*--ep = n + '0';
return (ep);
}
/*
* Attach a found device. Allocates memory for device variables.
*/
struct device *
config_attach(parent, cf, aux, print)
register struct device *parent;
register struct cfdata *cf;
register void *aux;
cfprint_t print;
{
register struct device *dev;
register struct cfdriver *cd;
register struct cfattach *ca;
register size_t lname, lunit;
register char *xunit;
int myunit;
char num[10];
cd = cf->cf_driver;
ca = cf->cf_attach;
if (ca->ca_devsize < sizeof(struct device))
panic("config_attach");
#ifndef __BROKEN_CONFIG_UNIT_USAGE
if (cf->cf_fstate == FSTATE_STAR) {
for (myunit = cf->cf_unit; myunit < cd->cd_ndevs; myunit++)
if (cd->cd_devs[myunit] == NULL)
break;
/*
* myunit is now the unit of the first NULL device pointer,
* or max(cd->cd_ndevs,cf->cf_unit).
*/
} else {
myunit = cf->cf_unit;
#else /* __BROKEN_CONFIG_UNIT_USAGE */
myunit = cf->cf_unit;
if (cf->cf_fstate == FSTATE_STAR)
cf->cf_unit++;
else {
#endif /* __BROKEN_CONFIG_UNIT_USAGE */
KASSERT(cf->cf_fstate == FSTATE_NOTFOUND);
cf->cf_fstate = FSTATE_FOUND;
}
/* compute length of name and decimal expansion of unit number */
lname = strlen(cd->cd_name);
xunit = number(&num[sizeof(num)], myunit);
lunit = &num[sizeof(num)] - xunit;
if (lname + lunit >= sizeof(dev->dv_xname))
panic("config_attach: device name too long");
/* get memory for all device vars */
dev = (struct device *)malloc(ca->ca_devsize, M_DEVBUF,
cold ? M_NOWAIT : M_WAITOK);
if (!dev)
panic("config_attach: memory allocation for device softc failed");
memset(dev, 0, ca->ca_devsize);
TAILQ_INSERT_TAIL(&alldevs, dev, dv_list); /* link up */
dev->dv_class = cd->cd_class;
dev->dv_cfdata = cf;
dev->dv_unit = myunit;
memcpy(dev->dv_xname, cd->cd_name, lname);
memcpy(dev->dv_xname + lname, xunit, lunit);
dev->dv_parent = parent;
dev->dv_flags = DVF_ACTIVE; /* always initially active */
if (parent == ROOT)
printf("%s (root)", dev->dv_xname);
else {
printf("%s at %s", dev->dv_xname, parent->dv_xname);
if (print)
(void) (*print)(aux, (char *)0);
}
/* put this device in the devices array */
if (dev->dv_unit >= cd->cd_ndevs) {
/*
* Need to expand the array.
*/
int old = cd->cd_ndevs, new;
void **nsp;
if (old == 0)
new = MINALLOCSIZE / sizeof(void *);
else
new = old * 2;
while (new <= dev->dv_unit)
new *= 2;
cd->cd_ndevs = new;
nsp = malloc(new * sizeof(void *), M_DEVBUF,
cold ? M_NOWAIT : M_WAITOK);
if (nsp == 0)
panic("config_attach: %sing dev array",
old != 0 ? "expand" : "creat");
memset(nsp + old, 0, (new - old) * sizeof(void *));
if (old != 0) {
memcpy(nsp, cd->cd_devs, old * sizeof(void *));
free(cd->cd_devs, M_DEVBUF);
}
cd->cd_devs = nsp;
}
if (cd->cd_devs[dev->dv_unit])
panic("config_attach: duplicate %s", dev->dv_xname);
cd->cd_devs[dev->dv_unit] = dev;
/*
* Before attaching, clobber any unfound devices that are
* otherwise identical.
*/
#ifdef __BROKEN_CONFIG_UNIT_USAGE
/* bump the unit number on all starred cfdata for this device. */
#endif /* __BROKEN_CONFIG_UNIT_USAGE */
for (cf = cfdata; cf->cf_driver; cf++)
if (cf->cf_driver == cd && cf->cf_unit == dev->dv_unit) {
if (cf->cf_fstate == FSTATE_NOTFOUND)
cf->cf_fstate = FSTATE_FOUND;
#ifdef __BROKEN_CONFIG_UNIT_USAGE
if (cf->cf_fstate == FSTATE_STAR)
cf->cf_unit++;
#endif /* __BROKEN_CONFIG_UNIT_USAGE */
}
#ifdef __HAVE_DEVICE_REGISTER
device_register(dev, aux);
#endif
(*ca->ca_attach)(parent, dev, aux);
config_process_deferred(&deferred_config_queue, dev);
return (dev);
}
/*
* Detach a device. Optionally forced (e.g. because of hardware
* removal) and quiet. Returns zero if successful, non-zero
* (an error code) otherwise.
*
* Note that this code wants to be run from a process context, so
* that the detach can sleep to allow processes which have a device
* open to run and unwind their stacks.
*/
int
config_detach(dev, flags)
struct device *dev;
int flags;
{
struct cfdata *cf;
struct cfattach *ca;
struct cfdriver *cd;
#ifdef DIAGNOSTIC
struct device *d;
#endif
int rv = 0, i;
cf = dev->dv_cfdata;
#ifdef DIAGNOSTIC
if (cf->cf_fstate != FSTATE_FOUND && cf->cf_fstate != FSTATE_STAR)
panic("config_detach: bad device fstate");
#endif
ca = cf->cf_attach;
cd = cf->cf_driver;
/*
* Ensure the device is deactivated. If the device doesn't
* have an activation entry point, we allow DVF_ACTIVE to
* remain set. Otherwise, if DVF_ACTIVE is still set, the
* device is busy, and the detach fails.
*/
if (ca->ca_activate != NULL)
rv = config_deactivate(dev);
/*
* Try to detach the device. If that's not possible, then
* we either panic() (for the forced but failed case), or
* return an error.
*/
if (rv == 0) {
if (ca->ca_detach != NULL)
rv = (*ca->ca_detach)(dev, flags);
else
rv = EOPNOTSUPP;
}
if (rv != 0) {
if ((flags & DETACH_FORCE) == 0)
return (rv);
else
panic("config_detach: forced detach of %s failed (%d)",
dev->dv_xname, rv);
}
/*
* The device has now been successfully detached.
*/
#ifdef DIAGNOSTIC
/*
* Sanity: If you're successfully detached, you should have no
* children. (Note that because children must be attached
* after parents, we only need to search the latter part of
* the list.)
*/
for (d = TAILQ_NEXT(dev, dv_list); d != NULL;
d = TAILQ_NEXT(d, dv_list)) {
if (d->dv_parent == dev) {
printf("config_detach: detached device %s"
" has children %s\n", dev->dv_xname, d->dv_xname);
panic("config_detach");
}
}
#endif
/*
* Mark cfdata to show that the unit can be reused, if possible.
*/
#ifdef __BROKEN_CONFIG_UNIT_USAGE
/*
* Note that we can only re-use a starred unit number if the unit
* being detached had the last assigned unit number.
*/
#endif /* __BROKEN_CONFIG_UNIT_USAGE */
for (cf = cfdata; cf->cf_driver; cf++) {
if (cf->cf_driver == cd) {
if (cf->cf_fstate == FSTATE_FOUND &&
cf->cf_unit == dev->dv_unit)
cf->cf_fstate = FSTATE_NOTFOUND;
#ifdef __BROKEN_CONFIG_UNIT_USAGE
if (cf->cf_fstate == FSTATE_STAR &&
cf->cf_unit == dev->dv_unit + 1)
cf->cf_unit--;
#endif /* __BROKEN_CONFIG_UNIT_USAGE */
}
}
/*
* Unlink from device list.
*/
TAILQ_REMOVE(&alldevs, dev, dv_list);
/*
* Remove from cfdriver's array, tell the world, and free softc.
*/
cd->cd_devs[dev->dv_unit] = NULL;
if ((flags & DETACH_QUIET) == 0)
printf("%s detached\n", dev->dv_xname);
free(dev, M_DEVBUF);
/*
* If the device now has no units in use, deallocate its softc array.
*/
for (i = 0; i < cd->cd_ndevs; i++)
if (cd->cd_devs[i] != NULL)
break;
if (i == cd->cd_ndevs) { /* nothing found; deallocate */
free(cd->cd_devs, M_DEVBUF);
cd->cd_devs = NULL;
cd->cd_ndevs = 0;
}
/*
* Return success.
*/
return (0);
}
int
config_activate(dev)
struct device *dev;
{
struct cfattach *ca = dev->dv_cfdata->cf_attach;
int rv = 0, oflags = dev->dv_flags;
if (ca->ca_activate == NULL)
return (EOPNOTSUPP);
if ((dev->dv_flags & DVF_ACTIVE) == 0) {
dev->dv_flags |= DVF_ACTIVE;
rv = (*ca->ca_activate)(dev, DVACT_ACTIVATE);
if (rv)
dev->dv_flags = oflags;
}
return (rv);
}
int
config_deactivate(dev)
struct device *dev;
{
struct cfattach *ca = dev->dv_cfdata->cf_attach;
int rv = 0, oflags = dev->dv_flags;
if (ca->ca_activate == NULL)
return (EOPNOTSUPP);
if (dev->dv_flags & DVF_ACTIVE) {
dev->dv_flags &= ~DVF_ACTIVE;
rv = (*ca->ca_activate)(dev, DVACT_DEACTIVATE);
if (rv)
dev->dv_flags = oflags;
}
return (rv);
}
/*
* Defer the configuration of the specified device until all
* of its parent's devices have been attached.
*/
void
config_defer(dev, func)
struct device *dev;
void (*func) __P((struct device *));
{
struct deferred_config *dc;
if (dev->dv_parent == NULL)
panic("config_defer: can't defer config of a root device");
#ifdef DIAGNOSTIC
for (dc = TAILQ_FIRST(&deferred_config_queue); dc != NULL;
dc = TAILQ_NEXT(dc, dc_queue)) {
if (dc->dc_dev == dev)
panic("config_defer: deferred twice");
}
#endif
dc = malloc(sizeof(*dc), M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
if (dc == NULL)
panic("config_defer: unable to allocate callback");
dc->dc_dev = dev;
dc->dc_func = func;
TAILQ_INSERT_TAIL(&deferred_config_queue, dc, dc_queue);
config_pending_incr();
}
/*
* Defer some autoconfiguration for a device until after interrupts
* are enabled.
*/
void
config_interrupts(dev, func)
struct device *dev;
void (*func) __P((struct device *));
{
struct deferred_config *dc;
/*
* If interrupts are enabled, callback now.
*/
if (cold == 0) {
(*func)(dev);
return;
}
#ifdef DIAGNOSTIC
for (dc = TAILQ_FIRST(&interrupt_config_queue); dc != NULL;
dc = TAILQ_NEXT(dc, dc_queue)) {
if (dc->dc_dev == dev)
panic("config_interrupts: deferred twice");
}
#endif
dc = malloc(sizeof(*dc), M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
if (dc == NULL)
panic("config_interrupts: unable to allocate callback");
dc->dc_dev = dev;
dc->dc_func = func;
TAILQ_INSERT_TAIL(&interrupt_config_queue, dc, dc_queue);
config_pending_incr();
}
/*
* Process a deferred configuration queue.
*/
static void
config_process_deferred(queue, parent)
struct deferred_config_head *queue;
struct device *parent;
{
struct deferred_config *dc, *ndc;
for (dc = TAILQ_FIRST(queue); dc != NULL; dc = ndc) {
ndc = TAILQ_NEXT(dc, dc_queue);
if (parent == NULL || dc->dc_dev->dv_parent == parent) {
TAILQ_REMOVE(queue, dc, dc_queue);
(*dc->dc_func)(dc->dc_dev);
free(dc, M_DEVBUF);
config_pending_decr();
}
}
}
/*
* Manipulate the config_pending semaphore.
*/
void
config_pending_incr()
{
config_pending++;
}
void
config_pending_decr()
{
#ifdef DIAGNOSTIC
if (config_pending == 0)
panic("config_pending_decr: config_pending == 0");
#endif
config_pending--;
if (config_pending == 0)
wakeup((void *)&config_pending);
}
/*
* Attach an event. These must come from initially-zero space (see
* commented-out assignments below), but that occurs naturally for
* device instance variables.
*/
void
evcnt_attach(dev, name, ev)
struct device *dev;
const char *name;
struct evcnt *ev;
{
#ifdef DIAGNOSTIC
if (strlen(name) >= sizeof(ev->ev_name))
panic("evcnt_attach");
#endif
/* ev->ev_next = NULL; */
ev->ev_dev = dev;
/* ev->ev_count = 0; */
strcpy(ev->ev_name, name);
TAILQ_INSERT_TAIL(&allevents, ev, ev_list);
}
/*
* Detach an event.
*/
void
evcnt_detach(ev)
struct evcnt *ev;
{
TAILQ_REMOVE(&allevents, ev, ev_list);
}
| [
"mouse@Rodents-Montreal.ORG"
] | mouse@Rodents-Montreal.ORG |
db062363dca069a328c4eaf9bd72feb4ad104ec6 | da7c499625123f5d1a28e3d75b037523df11ccb5 | /devel/coda/src/rc/motif/src.s/MultiList.c | 4d5750945c3b9e14b62ea9adcefb0040ba486950 | [] | no_license | emuikernel/BDXDaq | 84d947b0a4c0c1799a855dbe6c59e9560a8fc4e2 | cf678d3b71bdfb95996e8b7e97ad3657ef98262f | refs/heads/master | 2021-01-18T07:26:38.855967 | 2015-06-08T15:45:58 | 2015-06-08T15:45:58 | 48,211,085 | 3 | 2 | null | 2015-12-18T02:56:53 | 2015-12-18T02:56:52 | null | UTF-8 | C | false | false | 165,060 | c | /****************************************************************************
MultiList.c
This code is based on Brian Totty MultiList widget(FWF) and the
Athena List source which is why the MIT copyright notice appears below.
May, 1992, Marc QUINTON
see the Copyright(c) notice below.
****************************************************************************/
/* Copyright(c) 1992 STNA/7 95 rue Henri Rochefort 91025 EVRY Cedex FRANCE
* All rights reserved
* Permission to use, copy, modify and distribute this material for
* any purpose and without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies, and that the name of STNA not be used in advertising
* or publicity pertaining to this material without the specific,
* prior written permission of an authorized representative of
* STNA.
*
* STNA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
* PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
* FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE
* SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL STNA OR
* ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
* LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
* ING TO THE SOFTWARE.
*/
/*
* Copyright 1989 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Original Athena Author: Chris D. Peterson, MIT X Consortium
*/
#include <stdio.h>
#include <ctype.h>
#include "MultiListP.h"
static char id[] =
"MultiList widget Copyright(c) May 1992 STNA/France Marc QUINTON";
static char version[] = "MultiList widget version 2.0";
/*===========================================================================*
D E C L A R A T I O N S A N D D E F I N I T I O N S
*===========================================================================*/
Pixmap XmuCreateStippledPixmap();
#define FontAscent(f) ((f)->max_bounds.ascent)
#define FontDescent(f) ((f)->max_bounds.descent)
#define FontH(f) (FontAscent(f) + FontDescent(f) + 2)
#define FontW(f,s) (XTextWidth(f,s,strlen(s)) + 1)
#define FontMaxCharW(f) ((f)->max_bounds.rbearing-(f)->min_bounds.lbearing+1)
#ifndef abs
#define abs(a) ((a) < 0 ? -(a) : (a))
#endif
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define XtStrlen(s) ((s) ? strlen(s) : 0)
#define TypeAlloc(t,n) (t *)XtMalloc(sizeof(t) * n)
#define TypeRealloc(ptr,t,n) (t *)XtRealloc(ptr,sizeof(t) * n)
#define StrCopy(s) strcpy(TypeAlloc(char,strlen(s)+1),s)
#define StrCopyRetLength(s,lp) strcpy(TypeAlloc(char,(*lp=(strlen(s)+1))),s)
#define CoreFieldOffset(f) XtOffset(Widget,core.f)
#define PrimitiveFieldOffset(f) XtOffset(MultiListWidget,primitive.f)
#define MultiListFieldOffset(f) XtOffset(MultiListWidget,multiList.f)
/*===========================================================================*
I N T E R N A L P R O C E D U R E D E C L A R A T I O N S
*===========================================================================*/
static void Initialize _ARGUMENTS(( MultiListWidget request,
MultiListWidget new ));
static void MultiListRealize _ARGUMENTS(( MultiListWidget mlw,
XtValueMask *valueMask,
XSetWindowAttributes *attrs ));
static void Destroy _ARGUMENTS(( MultiListWidget mlw ));
static void Redisplay _ARGUMENTS(( MultiListWidget mlw,
XEvent *event, Region rectangle_union ));
static XtGeometryResult
PreferredGeometry _ARGUMENTS(( MultiListWidget mlw,
XtWidgetGeometry *parent_idea,
XtWidgetGeometry *our_idea ));
static void Resize _ARGUMENTS(( MultiListWidget mlw ));
static Boolean SetValues _ARGUMENTS(( MultiListWidget cpl,
MultiListWidget rpl,
MultiListWidget npl ));
static void DestroyOldData _ARGUMENTS(( MultiListWidget mlw ));
static void InitializeNewData _ARGUMENTS(( MultiListWidget mlw ));
static void CreateNewGCs _ARGUMENTS(( MultiListWidget mlw ));
static void RecalcCoords _ARGUMENTS(( MultiListWidget mlw,
Boolean width_changeable,
Boolean height_changeable ));
static void NegotiateSizeChange _ARGUMENTS(( MultiListWidget mlw,
Dimension width,
Dimension height ));
static Boolean Layout _ARGUMENTS(( MultiListWidget mlw,
Boolean w_changeable,
Boolean h_changeable,
Dimension *w_ptr,
Dimension *h_ptr ));
static void
MultiListVertSliderMove _ARGUMENTS(( Widget w,
caddr_t closure,
XmScrollBarCallbackStruct *call_data ));
static void MultiListSetVerticalScrollbar _ARGUMENTS(( MultiListWidget mlw ));
static void MultiListDrawShadow _ARGUMENTS(( MultiListWidget mlw,
Boolean armed ));
static void MultiListSetClipRect _ARGUMENTS(( MultiListWidget mlw ));
static void MultiListUnsetClipRect _ARGUMENTS(( MultiListWidget mlw ));
static void RedrawAll _ARGUMENTS(( MultiListWidget mlw ));
static void RedrawItem _ARGUMENTS(( MultiListWidget mlw, int item_index ));
static void MultiListScroll _ARGUMENTS(( MultiListWidget mlw, int offset ));
static void MultiListRedrawArea _ARGUMENTS(( MultiListWidget mlw,
int x1, int y1, int w, int h ));
static void MultiListRefreshArea _ARGUMENTS(( MultiListWidget mlw,
int x1, int y1, int w, int h ));
static void RedrawRowColumn _ARGUMENTS(( MultiListWidget mlw,
int row, int column ));
static void PixelToRowColumn _ARGUMENTS(( MultiListWidget mlw, int x, int y,
int *row_ptr, int *column_ptr ));
static void RowColumnToPixels _ARGUMENTS(( MultiListWidget mlw,
int row, int col,
int *x_ptr, int *y_ptr,
int *w_ptr, int *h_ptr ));
static Boolean RowColumnToItem _ARGUMENTS(( MultiListWidget mlw, int row,
int column, int *item_ptr ));
static Boolean ItemToRowColumn _ARGUMENTS(( MultiListWidget mlw,
int item_index,
int *row_ptr, int *column_ptr ));
static void MultiListHandleMultiClick _ARGUMENTS(( MultiListWidget mlw,
int item_index ));
static void MultiListDoNotification _ARGUMENTS(( MultiListWidget mlw ));
static void MultiListSet _ARGUMENTS(( MultiListWidget mlw, XEvent *event,
String *params, Cardinal *num_params ));
static void MultiListSetMany _ARGUMENTS(( MultiListWidget mlw, XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListSetColumn _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListSetAll _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListSelect _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListUnselect _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListUnset _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListUnsetAll _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListUnsetMany _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListToggle _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListToggleMany _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListToggleAll _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListOpen _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListOpenMany _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void MultiListNotify _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static void _MultiListHighlightItem _ARGUMENTS(( MultiListWidget mlw,
int item_index ));
static void _MultiListUnhighlightItem _ARGUMENTS(( MultiListWidget mlw,
int item_index ));
static int _MultiListToggleItem _ARGUMENTS(( MultiListWidget mlw,
int item_index ));
static void MultiListBlinkingProc _ARGUMENTS((XtPointer client_data,
XtIntervalId *id));
static int NumColumnWidths _ARGUMENTS(( MultiListWidget mlw));
static Dimension TotalWidth _ARGUMENTS(( MultiListWidget mlw, int col));
static void ColumnGeometry _ARGUMENTS(( MultiListWidget mlw,
int col, int* x, int* w));
static int ColumnByPixel _ARGUMENTS(( MultiListWidget mlw, int x));
static void MultiListDrawSeparator _ARGUMENTS(( MultiListWidget mlw,
int col,
int y1, int y2 ));
static void MultiListDrawSeparatorT _ARGUMENTS ((MultiListWidget mlw,
int x,
int y1, int y2, int wd));
static void MultiListEraseSeparator _ARGUMENTS(( MultiListWidget mlw,
int x,
int y1,
int y2, int wd));
static void MultiListMoveSeparator _ARGUMENTS(( MultiListWidget mlw,
int x,
int y1, int y2, int wd));
static void MultiListTrackPointer _ARGUMENTS(( MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params ));
static int _PixelInsideSeparator _ARGUMENTS((MultiListWidget mlw,
int x, int y));
static void SeparatorGeometry _ARGUMENTS ((MultiListWidget mlw,
int ex, int ey,
int *x, int* y1, int *y2, int *sepw));
static void SeparatorAuxInfo _ARGUMENTS ((MultiListWidget mlw,
int ex, int ey,
int *col, int* minx, int* inix));
/*===========================================================================*
E X T E R N A L P R O C E D U R E D E C L A R A T I O N S
*===========================================================================*/
extern void _XmBackgroundColorDefault();
extern void _XmForegroundColorDefault();
/*===========================================================================*
R E S O U R C E I N I T I A L I Z A T I O N
*===========================================================================*/
static XtResource resources[] =
{
{XmNwidth, XmCWidth, XmRDimension, sizeof(Dimension),
CoreFieldOffset(width), XmRString, "0"},
{XmNheight, XmCHeight, XmRDimension, sizeof(Dimension),
CoreFieldOffset(height), XmRString, "0"},
{XmNbackground, XmCBackground, XmRPixel, sizeof (Pixel),
CoreFieldOffset(background_pixel),
XmRCallProc, (caddr_t) _XmBackgroundColorDefault},
{XmNforeground, XmCForeground, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(foreground),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNseparatorWidth, XmCSeparatorWidth, XmRDimension, sizeof (Dimension),
MultiListFieldOffset(sep_width), XmRImmediate, (caddr_t)0},
{XmNseparatorType, XmCSeparatorType, XmRSeparatorType,
sizeof(unsigned char), MultiListFieldOffset(sep_type),
XmRImmediate, (caddr_t) XmSHADOW_ETCHED_IN},
{XmNalignment, XmCAlignment, XmRAlignment,
sizeof(unsigned char), MultiListFieldOffset(alignment),
XmRImmediate, (XtPointer)XmALIGNMENT_BEGINNING},
{XmNaltForeground, XmCAltForeground, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[0]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNaltForeground1, XmCAltForeground1, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[1]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNaltForeground2, XmCAltForeground2, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[2]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNaltForeground3, XmCAltForeground3, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[3]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNaltForeground4, XmCAltForeground4, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[4]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNaltForeground5, XmCAltForeground5, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[5]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNaltForeground6, XmCAltForeground6, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[6]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNaltForeground7, XmCAltForeground7, XmRPixel, sizeof (Pixel),
MultiListFieldOffset(alt_fg[7]),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNhighlightForeground, XmCHForeground, XmRPixel, sizeof(Pixel),
MultiListFieldOffset(highlight_fg),
XmRCallProc, (caddr_t) _XmBackgroundColorDefault },
{XmNhighlightBackground, XmCHBackground, XmRPixel, sizeof(Pixel),
MultiListFieldOffset(highlight_bg),
XmRCallProc, (caddr_t) _XmForegroundColorDefault},
{XmNcolumnSpacing, XmCSpacing, XmRDimension, sizeof(Dimension),
MultiListFieldOffset(column_space), XmRImmediate, (caddr_t)8},
{XmNrowSpacing, XmCSpacing, XmRDimension, sizeof(Dimension),
MultiListFieldOffset(row_space), XmRImmediate, (caddr_t)0},
{XmNdefaultColumns, XmCColumns, XmRInt, sizeof(int),
MultiListFieldOffset(default_cols), XmRImmediate, (caddr_t)1},
{XmNforceColumns, XmCColumns, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(force_cols), XmRString, (caddr_t) "False"},
{XmNpasteBuffer, XmCBoolean, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(paste), XmRString, (caddr_t) "False"},
{XmNverticalList, XmCBoolean, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(row_major), XmRString, (caddr_t) "False"},
{XmNlongest, XmCLongest, XmRInt, sizeof(int),
MultiListFieldOffset(longest), XmRImmediate, (caddr_t)0},
{XmNnumberStrings, XmCNumberStrings, XmRInt, sizeof(int),
MultiListFieldOffset(nitems), XmRImmediate, (caddr_t)0},
{XmNfont, XmCFont, XmRFontStruct, sizeof(XFontStruct *),
MultiListFieldOffset(font),XmRString, "XtDefaultFont"},
{XmNlist, XmCList, XmRPointer, sizeof(char **),
MultiListFieldOffset(list), XmRString, NULL},
{XmNsensitiveArray, XmCList, XmRPointer, sizeof(Boolean *),
MultiListFieldOffset(sensitive_array), XmRString, NULL},
{XmNpreferredWidths, XmCList, XmRPointer, sizeof(Dimension *),
MultiListFieldOffset(col_widths), XmRString, NULL},
{XmNcallback, XmCCallback, XmRCallback, sizeof(caddr_t),
MultiListFieldOffset(callback), XmRCallback, NULL},
{XmNmaxSelectable, XmCValue, XmRInt, sizeof(int),
MultiListFieldOffset(max_selectable), XmRImmediate, (caddr_t) 1},
{XmNnotifyHighlights, XmCBoolean, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(notify_highlights), XmRString, "True"},
{XmNnotifyUnhighlights, XmCBoolean, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(notify_unhighlights), XmRString, "True"},
{XmNnotifyOpens, XmCBoolean, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(notify_opens), XmRString, "True"},
{XmNclickDelay, XmCClickDelay, XmRInt, sizeof(int),
MultiListFieldOffset(click_delay), XmRImmediate, (caddr_t)300},
{XmNuseMultiClick, XmCUseMultiClick, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(use_multi_click), XmRImmediate, (caddr_t) True},
{XmNcolumnWidth, XmCValue, XmRDimension, sizeof(Dimension),
MultiListFieldOffset(col_width), XmRImmediate, (caddr_t)0},
{XmNrowHeight, XmCValue, XmRDimension, sizeof(Dimension),
MultiListFieldOffset(row_height), XmRImmediate, (caddr_t)0},
{XmNuseScrollBar, XmCUseScrollBar, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(use_scrollBar), XmRString, (caddr_t) "True"},
/* blinking string */
{XmNblinkDelay, XmCValue, XmRInt, sizeof(int),
MultiListFieldOffset(blink_delay), XmRImmediate, (caddr_t)500},
{XmNblink, XmCBoolean, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(blink), XmRString, "True"},
{XmNreverseVideo, XmCBoolean, XmRBoolean, sizeof(Boolean),
MultiListFieldOffset(reverse_video), XmRString, "False"},
/* selection mechanisme */
{XmNselectCallback, XmCCallback, XmRCallback, sizeof(caddr_t),
MultiListFieldOffset(select_callback), XmRCallback, NULL},
/* separator move mechanisme */
{XmNsepMoveCallback, XmCCallback, XmRCallback, sizeof(caddr_t),
MultiListFieldOffset(sep_move_callback), XmRCallback, NULL},
};
/*===========================================================================*
A C T I O N A N D T R A N S L A T I O N T A B L E S
*===========================================================================*/
static char defaultTranslations[] =
" <Btn1Motion>: SetMany()\n\
Shift<Btn1Down>: SetMany()\n\
Ctrl<Btn1Down>: SetAll()\n\
Alt<Btn1Down>: Select()\n\
Alt<Btn2Down>: Unselect()\n\
None<Btn1Down>: Set()\n\
None<Btn2Down>: Toggle()\n\
Shift<Btn2Down>: ToggleMany()\n\
<Btn2Motion>: ToggleMany()\n\
Ctrl<Btn2Down>: ToggleAll()\n\
None<Btn3Down>: Unset()\n\
Shift<Btn3Down>: UnsetMany()\n\
<Btn3Motion>: UnsetMany()\n\
Ctrl<Btn3Down>: UnsetAll()\n\
<Motion>: TrackPointer()\n\
<BtnUp>: Notify()";
static XtActionsRec actions[] =
{
{"Notify", (XtActionProc)MultiListNotify},
{"Set", (XtActionProc)MultiListSet},
{"SetMany", (XtActionProc)MultiListSetMany},
{"SetColumn", (XtActionProc)MultiListSetColumn},
{"SetAll", (XtActionProc)MultiListSetAll},
{"Toggle", (XtActionProc)MultiListToggle},
{"ToggleMany", (XtActionProc)MultiListToggleMany},
{"ToggleAll", (XtActionProc)MultiListToggleAll},
{"Open", (XtActionProc)MultiListOpen},
{"OpenMany", (XtActionProc)MultiListOpenMany},
{"Unset", (XtActionProc)MultiListUnset},
{"UnsetMany", (XtActionProc)MultiListUnsetMany},
{"UnsetAll", (XtActionProc)MultiListUnsetAll},
{"Select", (XtActionProc)MultiListSelect},
{"Unselect", (XtActionProc)MultiListUnselect},
{"TrackPointer", (XtActionProc)MultiListTrackPointer},
{NULL,NULL}
};
/*===========================================================================*
Callback Functions
These are the callback routines for the scrollbar actions.
*===========================================================================*/
static XtCallbackRec VSCallBack[] =
{
{(XtCallbackProc )MultiListVertSliderMove, (caddr_t) NULL},
{NULL, (caddr_t) NULL},
};
/*===========================================================================*
C L A S S A L L O C A T I O N
*===========================================================================*/
MultiListClassRec multiListClassRec =
{
{/* core class fields */
/* superclass */ (WidgetClass)&xmPrimitiveClassRec,
/* class_name */ "MultiList",
/* widget_size */ sizeof(MultiListRec),
/* class_initialize */ NULL,
/* class_part_initialize*/ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ MultiListRealize,
/* actions */ actions,
/* num_actions */ XtNumber(actions),
/* resources */ resources,
/* resource_count */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ FALSE,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ Resize,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ defaultTranslations,
/* query_geometry */ PreferredGeometry,
/* display_accelerator */ XtInheritDisplayAccelerator,
/* extension */ NULL,
},
{/* primitive class */
/* border highlight */ NULL /*_XtInherit */,
/* border unhighlight */ NULL /*_XtInherit*/,
/* translations */ NULL /*XtInheritTranslations*/,
/* arm_and_activate */ NULL /*_XtInherit*/,
/* syn resources */ NULL,
/* num_syn_resources */ 0,
/* extension */ NULL,
},
{/* MultiList class fields */
/* empty */ 0
}
};
WidgetClass multiListWidgetClass = (WidgetClass)&multiListClassRec;
/*===========================================================================*
T O O L K I T M E T H O D S
*===========================================================================*/
/*---------------------------------------------------------------------------*
Initialize()
This procedure is called by the X toolkit to initialize
the widget instance. The hook to this routine is in the
initialize part of the core part of the class.
*---------------------------------------------------------------------------*/
/* ARGSUSED */
#if defined (__STDC__) && !defined(_NO_PROTO)
static void Initialize (MultiListWidget request, MultiListWidget new)
#else
static void Initialize (request, new)
MultiListWidget request;
MultiListWidget new;
#endif
{
MultiListWidget mlw;
mlw = (MultiListWidget)new;
CreateNewGCs(new);
InitializeNewData(new);
/* used by the scrolling manager */
new->multiList.pixel_offset = 0;
/* initialize data used by MultiList widget */
MultiListClipSet(mlw) = False;
mlw->multiList.vscrollBar = NULL;
/* timer features */
mlw->multiList.last_button_time = 0;
MultiListClickNumber(new) = 0;
/* blink features */
new->multiList.blink_on = False;
new->multiList.num_blinking = 0;
new->multiList.blink_timer = 0;
/* cursor features */
new->multiList.mcursor = XCreateFontCursor(XtDisplay(mlw),
XC_sb_h_double_arrow);
/* move separator flag */
new->multiList.move_sep = 0;
/* Now look at our parent and see if it's a ScrolledWindow.
* If it is, create the scrollbars and set up all the scrolling stuff.
*/
if ( (XtClass(XtParent(new)) != xmScrolledWindowWidgetClass)
|| ( !MultiListUseScrollBar(new)))
{
RecalcCoords(new,(MultiListWidth(new) == 0),
(MultiListHeight(new) == 0));
new->multiList.scrolled_win = NULL;
return;
}
new->multiList.scrolled_win = XtParent(new);
new->multiList.vscrollBar = XtVaCreateManagedWidget("vscrollBar",
xmScrollBarWidgetClass, new->multiList.scrolled_win,
XmNorientation, XmVERTICAL,
XmNincrementCallback, (XtArgVal) VSCallBack,
XmNdecrementCallback, (XtArgVal) VSCallBack,
XmNpageIncrementCallback, (XtArgVal) VSCallBack,
XmNpageDecrementCallback, (XtArgVal) VSCallBack,
XmNdragCallback, (XtArgVal) VSCallBack,
NULL);
#if (XmVERSION != 2)
XtAddCallback ( (Widget) mlw, XmNdestroyCallback, _XmDestroyParentCallback, NULL);
#endif
RecalcCoords(new, False, False);
MultiListSetVerticalScrollbar(new);
XmScrolledWindowSetAreas(
new->multiList.scrolled_win,
NULL,
new->multiList.vscrollBar,
(Widget)new);
} /* Initialize */
/*---------------------------------------------------------------*
MultiListRealize()
This function is called to realize a ScrolledList widget.
*---------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListRealize ( MultiListWidget mlw, XtValueMask *valueMask,
XSetWindowAttributes *attrs )
#else
static void MultiListRealize (mlw, valueMask, attrs )
MultiListWidget mlw;
XtValueMask *valueMask;
XSetWindowAttributes *attrs;
#endif
{
XtCreateWindow((Widget)mlw,InputOutput,(Visual *)CopyFromParent,
*valueMask,attrs);
} /* End MultiListRealize */
/*---------------------------------------------------------------------------*
Destroy()
This procedure is called by the X toolkit to destroy
the widget instance. We need to destroy GC, XtCallbackList,
XtIntervalId.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void Destroy ( MultiListWidget mlw )
#else
static void Destroy (mlw)
MultiListWidget mlw;
#endif
{
int i = 0;
/* The GCs */
XtReleaseGC ((Widget)mlw, MultiListEraseGC(mlw));
XtReleaseGC ((Widget)mlw, MultiListDrawGC(mlw));
XtReleaseGC ((Widget)mlw, MultiListGrayGC(mlw));
XtReleaseGC ((Widget)mlw, MultiListHighlightForeGC(mlw));
XtReleaseGC ((Widget)mlw, MultiListHighlightBackGC(mlw));
XtReleaseGC ((Widget)mlw, MultiListSepGC(mlw));
for (i = 0; i < 8; i++)
XtReleaseGC ((Widget)mlw, MultiListAltFgGC(mlw, i));
/* allocated data in the MultiListWidget */
DestroyOldData(mlw);
/* Destroy of mlw->multiList.vscrollBar is done by XmNdestroy callback
which has been set up in Initialize() methode.
So we don't need to do XtRemoveAllCallbacks for widget mlw->multiList.vscrollBar
*/
/* The blinking time-out proc */
if (mlw->multiList.blink_timer != 0)
{
XtRemoveTimeOut(mlw->multiList.blink_timer);
mlw->multiList.blink_timer = 0;
}
} /* Destroy() */
/*---------------------------------------------------------------------------*
Redisplay(mlw,event,rectangle_union)
This routine redraws the MultiList widget <mlw> based on the exposure
region requested in <event>.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void Redisplay( MultiListWidget mlw,
XEvent *event, Region rectangle_union )
#else
static void Redisplay(mlw, event, rectangle_union )
MultiListWidget mlw;
XEvent *event;
Region rectangle_union;
#endif
{
#ifdef DEBUG
/* if(event == NULL)
printf ("MultiList Redisplay, event = NULL\n");
else
printf ("MultiList Redisplay, event_count = %d\n", event->xexpose.count); */
#endif
if (event == NULL)
{
int border;
border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
XClearWindow(XtDisplay(mlw),XtWindow(mlw));
MultiListSetClipRect(mlw);
MultiListRedrawArea(mlw, border, border,
MultiListWidth(mlw),MultiListHeight(mlw));
}
else
{
MultiListSetClipRect(mlw);
MultiListRedrawArea(mlw,
event->xexpose.x,
event->xexpose.y,
event->xexpose.width,
event->xexpose.height);
}
/* restore the clip mask */
MultiListUnsetClipRect(mlw);
MultiListDrawShadow(mlw, True);
} /* End Redisplay */
/*---------------------------------------------------------------------------*
PreferredGeometry(mlw,parent_idea,our_idea)
This routine is called by the parent to tell us about the
parent's idea of our width and/or height. We then suggest
our preference through <our_idea> and return the information
to the parent.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static XtGeometryResult PreferredGeometry (MultiListWidget mlw,
XtWidgetGeometry *parent_idea,
XtWidgetGeometry *our_idea )
#else
static XtGeometryResult PreferredGeometry (mlw, parent_idea, our_idea )
MultiListWidget mlw;
XtWidgetGeometry *parent_idea;
XtWidgetGeometry *our_idea;
#endif
{
Dimension nw,nh;
Boolean parent_wants_w,parent_wants_h,we_changed_size;
/* if (!XtIsRealized(mlw))
return (XtGeometryYes); */
parent_wants_w = (parent_idea->request_mode) & CWWidth;
parent_wants_h = (parent_idea->request_mode) & CWHeight;
if (parent_wants_w)
nw = parent_idea->width;
else
nw = MultiListWidth(mlw);
if (parent_wants_h)
nh = parent_idea->height;
else
nh = MultiListHeight(mlw);
our_idea->request_mode = 0;
if (!parent_wants_w && !parent_wants_h) return(XtGeometryYes);
if (mlw->multiList.scrolled_win == NULL )
we_changed_size = Layout(mlw,!parent_wants_w,!parent_wants_h,&nw,&nh);
else
{
/* prefer to resize at our idea */
we_changed_size = Layout(mlw, False, True, &nw, &nh);
}
our_idea->request_mode = (CWWidth | CWHeight);
our_idea->width = nw;
our_idea->height = nh;
if (we_changed_size)
/* prefer to resize at our idea */
return(XtGeometryAlmost);
else
/* the size is correct, dont change the size */
return(XtGeometryYes);
} /* End PreferredGeometry */
/*---------------------------------------------------------------------------*
Resize(mlw)
This function is called when the widget is being resized. It
recalculates the layout of the widget.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void Resize ( MultiListWidget mlw )
#else
static void Resize (mlw )
MultiListWidget mlw;
#endif
{
Dimension width,height;
Boolean size_changed;
width = MultiListWidth(mlw);
height = MultiListHeight(mlw);
size_changed = Layout(mlw,False, False,&width,&height);
MultiListSetVerticalScrollbar(mlw);
} /* End Resize */
/*---------------------------------------------------------------------------*
AltGCChanged (cpl, npl, dpl)
This function checks whether any altGC have been changed
This is called after pointer
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static int AltGCChanged(MultiListWidget cpl,
MultiListWidget rpl,
MultiListWidget npl)
#else
static int AltGCChanged (cpl, rpl, npl)
MultiListWidget cpl;
MultiListWidget rpl;
MultiListWidget npl;
#endif
{
int i = 0;
for (i = 0; i < 8; i++) {
if (MultiListAltFgGC (cpl, i) != MultiListAltFgGC (npl, i))
return 1;
}
return 0;
}
/*---------------------------------------------------------------------------*
SetValues(cpl,rpl,npl)
This routine is called when the user is changing resources. <cpl>
is the current widget before the user's changes have been instituted.
<rpl> includes the original changes as requested by the user. <npl>
is the new resulting widget with the requested changes and with all
superclass changes already made.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static Boolean SetValues (MultiListWidget cpl,
MultiListWidget rpl,
MultiListWidget npl)
#else
static Boolean SetValues (cpl, rpl, npl)
MultiListWidget cpl;
MultiListWidget rpl;
MultiListWidget npl;
#endif
{
Boolean redraw,recalc;
int i = 0;
redraw = False;
recalc = False;
/* Graphic Context Changes */
if ((MultiListFG(cpl) != MultiListFG(npl)) ||
(MultiListBG(cpl) != MultiListBG(npl)) ||
(MultiListHighlightFG(cpl) != MultiListHighlightFG(npl)) ||
(MultiListHighlightBG(cpl) != MultiListHighlightBG(npl)) ||
(MultiListFont(cpl) != MultiListFont(npl)) ||
AltGCChanged (cpl, rpl, npl) )
{
XtDestroyGC(MultiListEraseGC(cpl));
XtDestroyGC(MultiListDrawGC(cpl));
XtDestroyGC(MultiListHighlightForeGC(cpl));
XtDestroyGC(MultiListHighlightBackGC(cpl));
XtDestroyGC(MultiListGrayGC(cpl));
for (i = 0; i < 8; i++)
XtDestroyGC(MultiListAltFgGC(cpl, i));
CreateNewGCs(npl);
redraw = True;
}
/* Changes That Require Data Initialization */
if ((MultiListList(cpl) != MultiListList(npl)) ||
(MultiListSensitiveArray(cpl) != MultiListSensitiveArray(npl)) ||
(MultiListSensitive(cpl) != MultiListSensitive(npl)) ||
(MultiListAncesSensitive(cpl) != MultiListAncesSensitive(npl)) ||
(MultiListNumItems(cpl) != MultiListNumItems(npl)) ||
(MultiListMaxSelectable(cpl) != MultiListMaxSelectable(npl)))
{
DestroyOldData(cpl);
InitializeNewData(npl);
recalc = True;
redraw = True;
}
/* Changes That Require Recalculating Coordinates */
if ((MultiListWidth(cpl) != MultiListWidth(npl)) ||
(MultiListHeight(cpl) != MultiListHeight(npl)) ||
(MultiListColumnSpace(cpl) != MultiListColumnSpace(npl)) ||
(MultiListRowSpace(cpl) != MultiListRowSpace(npl)) ||
(MultiListDefaultCols(cpl) != MultiListDefaultCols(npl)) ||
(MultiListPrefWidths(cpl) != MultiListPrefWidths(npl)) ||
(MultiListSepWidth(cpl) != MultiListSepWidth(npl)) ||
((MultiListForceCols(cpl) != MultiListForceCols(npl)) &&
(MultiListNumCols(cpl) != MultiListNumCols(npl))) ||
(MultiListRowMajor(cpl) != MultiListRowMajor(npl)) ||
(MultiListFont(cpl) != MultiListFont(npl)) ||
(MultiListAlignment(cpl) != MultiListAlignment(npl)) ||
(MultiListLongest(cpl) != MultiListLongest(npl)))
{
if(MultiListLongest(cpl) == MultiListLongest(npl))
MultiListLongest(npl) = 0;
recalc = True;
redraw = True;
}
if (MultiListColWidth(cpl) != MultiListColWidth(npl))
{
XtWarning("columnWidth Resource Is Read-Only");
MultiListColWidth(npl) = MultiListColWidth(cpl);
}
if (MultiListRowHeight(cpl) != MultiListRowHeight(npl))
{
XtWarning("rowHeight Resource Is Read-Only");
MultiListRowHeight(npl) = MultiListRowHeight(cpl);
}
if (recalc)
{
RecalcCoords(npl,!MultiListWidth(npl),!MultiListHeight(npl));
MultiListSetVerticalScrollbar(npl);
}
if (!XtIsRealized((Widget)cpl))
return(False);
else
return(redraw);
} /* End SetValues */
/*===========================================================================*
D A T A I N I T I A L I Z A T I O N
*===========================================================================*/
/*---------------------------------------------------------------------------*
DestroyOldData(mlw)
This routine frees the internal list item array and sets the
item count to 0. This is normally done immediately before
calling InitializeNewData() to rebuild the internal item
array from new user specified arrays.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void DestroyOldData (MultiListWidget mlw)
#else
static void DestroyOldData (mlw)
MultiListWidget mlw;
#endif
{
int i;
if (MultiListItemArray(mlw) != NULL) /* Free Old List */
{
for (i = 0; i < MultiListNumItems(mlw); i++)
{
XtFree(MultiListItemString(MultiListNthItem(mlw,i)));
}
XtFree(MultiListItemArray(mlw));
}
if (MultiListSelArray(mlw) != NULL) XtFree(MultiListSelArray(mlw));
MultiListSelArray(mlw) = NULL;
MultiListNumSelected(mlw) = 0;
MultiListItemArray(mlw) = NULL;
MultiListNumItems(mlw) = 0;
} /* End DestroyOldData */
/*---------------------------------------------------------------------------*
InitializeNewData(mlw)
This routine takes a MultiList widget <mlw> and builds up new
data item tables based on the string list and the sensitivity array.
All previous data should have already been freed. If the number
of items is 0, they will be counted, so the array must be NULL
terminated. If the list of strings is NULL, this is treated as
a list of 0 elements. If the sensitivity array is NULL, all
items are treated as sensitive.
When this routine is done, the string list and sensitivity array
fields will all be set to NULL, and the widget will not reference
them again.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void InitializeNewData (MultiListWidget mlw)
#else
static void InitializeNewData (mlw)
MultiListWidget mlw;
#endif
{
int i;
MultiListItem *item;
String *string_array;
string_array = MultiListList(mlw);
if (MultiListNumItems(mlw) == 0) /* Count The Elements */
{
if (MultiListList(mlw) == NULL) /* No elements */
{
MultiListNumItems(mlw) = 0;
}
else
{
for (i = 0; string_array[i] != NULL; i ++);
MultiListNumItems(mlw) = i;
}
}
if (MultiListNumItems(mlw) == 0) /* No Items */
{
MultiListItemArray(mlw) = NULL;
}
else
{
MultiListItemArray(mlw) = TypeAlloc(MultiListItem,MultiListNumItems(mlw));
for (i = 0; i < MultiListNumItems(mlw); i++)
{
item = MultiListNthItem(mlw,i);
if (MultiListSensitiveArray(mlw) == NULL ||
(MultiListSensitiveArray(mlw)[i] == True))
{
MultiListItemSensitive(item) = True;
}
else
{
MultiListItemSensitive(item) = False;
}
MultiListItemString(item) = StrCopy(string_array[i]);
MultiListItemHighlighted(item) = False;
MultiListItemFgIndex(item) = -1;
}
}
if (MultiListMaxSelectable(mlw) == 0)
{
MultiListSelArray(mlw) = NULL;
MultiListNumSelected(mlw) = 0;
}
else
{
MultiListSelArray(mlw) = TypeAlloc(int,MultiListMaxSelectable(mlw));
MultiListNumSelected(mlw) = 0;
}
MultiListList(mlw) = NULL;
MultiListSensitiveArray(mlw) = NULL;
} /* End InitializeNewData */
/*---------------------------------------------------------------------------*
CreateNewGCs(mlw)
This routine takes a MultiList widget <mlw> and creates a new set of
graphic contexts for the widget based on the colors, fonts, etc.
in the widget. Any previous GCs are assumed to have already been
destroyed.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void CreateNewGCs (MultiListWidget mlw)
#else
static void CreateNewGCs (mlw)
MultiListWidget mlw;
#endif
{
XGCValues values;
unsigned int attribs;
int i = 0;
attribs = GCForeground | GCBackground | GCFont | GCFunction;
values.foreground = MultiListFG(mlw) ^ MultiListBG(mlw);
values.background = MultiListBG(mlw);
values.font = MultiListFont(mlw)->fid;
values.function = GXxor;
MultiListSepGC(mlw) = XtGetGC((Widget)mlw, attribs, &values);
attribs = GCForeground | GCBackground | GCFont;
values.foreground = MultiListFG(mlw);
values.background = MultiListBG(mlw);
values.font = MultiListFont(mlw)->fid;
MultiListDrawGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
values.foreground = MultiListBG(mlw);
MultiListEraseGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
values.foreground = MultiListHighlightFG(mlw);
values.background = MultiListHighlightBG(mlw);
MultiListHighlightForeGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
values.foreground = MultiListHighlightBG(mlw);
values.background = MultiListHighlightBG(mlw);
MultiListHighlightBackGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
for (i = 0; i < 8; i++) {
values.foreground = MultiListAltFG(mlw, i);
values.background = MultiListBG(mlw);
values.font = MultiListFont(mlw)->fid;
MultiListAltFgGC(mlw, i) = XtGetGC ((Widget)mlw, attribs, &values);
}
attribs |= GCTile | GCFillStyle;
values.foreground = MultiListFG(mlw);
values.background = MultiListBG(mlw);
values.fill_style = FillTiled;
values.tile = XmuCreateStippledPixmap(XtScreen(mlw),MultiListFG(mlw),
MultiListBG(mlw),MultiListDepth(mlw));
MultiListGrayGC(mlw) = XtGetGC((Widget)mlw,attribs,&values);
} /* End CreateNewGCs */
/*===========================================================================*
L A Y O U T A N D G E O M E T R Y M A N A G E M E N T
*===========================================================================*/
/*---------------------------------------------------------------------------*
RecalcCoords(mlw,width_changeable,height_changeable)
This routine takes a MultiList widget <mlw> and recalculates
the coordinates, and item placement based on the current
width, height, and list of items. The <width_changeable> and
<height_changeable> indicate if the width and/or height can
be arbitrarily set.
This routine requires that the internal list data be initialized.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void RecalcCoords (MultiListWidget mlw,
Boolean width_changeable,
Boolean height_changeable)
#else
static void RecalcCoords (mlw, width_changeable, height_changeable)
MultiListWidget mlw;
Boolean width_changeable;
Boolean height_changeable;
#endif
{
String str;
Dimension width,height;
register int i,text_width;
width = MultiListWidth(mlw);
height = MultiListHeight(mlw);
if (MultiListNumItems(mlw) != 0 && MultiListLongest(mlw) == 0)
{
for (i = 0; i < MultiListNumItems(mlw); i++)
{
str = MultiListItemString(MultiListNthItem(mlw,i));
text_width = FontW(MultiListFont(mlw),str);
MultiListLongest(mlw) = max(MultiListLongest(mlw),text_width);
}
}
if (Layout(mlw,width_changeable,height_changeable,&width,&height))
{
NegotiateSizeChange(mlw,width,height);
}
} /* End RecalcCoords */
/*---------------------------------------------------------------------------*
NegotiateSizeChange(mlw,width,height)
This routine tries to change the MultiList widget <mlw> to have the
new size <width> by <height>. A negotiation will takes place
to try to change the size. The resulting size is not necessarily
the requested size.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void NegotiateSizeChange (MultiListWidget mlw,
Dimension width, Dimension height)
#else
static void NegotiateSizeChange (mlw, width, height)
MultiListWidget mlw;
Dimension width;
Dimension height;
#endif
{
int attempt_number;
Boolean w_fixed,h_fixed;
Dimension *w_ptr,*h_ptr;
XtWidgetGeometry request,reply;
request.request_mode = CWWidth | CWHeight;
request.width = width;
request.height = height;
for (attempt_number = 1; attempt_number <= 3; attempt_number++)
{
switch (XtMakeGeometryRequest((Widget)mlw,&request,&reply))
{
case XtGeometryYes:
return;
case XtGeometryNo:
return;
case XtGeometryAlmost:
switch (attempt_number)
{
case 1:
w_fixed = (request.width != reply.width);
h_fixed = (request.height != reply.height);
w_ptr = &(reply.width);
h_ptr = &(reply.height);
Layout(mlw,!w_fixed,!h_fixed,w_ptr,h_ptr);
break;
case 2:
w_ptr = &(reply.width);
h_ptr = &(reply.height);
Layout(mlw,False,False,w_ptr,h_ptr);
break;
case 3:
return;
}
break;
default:
XtAppWarning(XtWidgetToApplicationContext((Widget)mlw),
"MultiList Widget: Unknown geometry return.");
break;
}
request = reply;
}
} /* End NegotiateSizeChange */
/*---------------------------------------------------------------------------*
Boolean Layout(mlw,w_changeable,h_changeable,w_ptr,h_ptr)
This routine tries to generate a layout for the MultiList widget
<mlw>. The Layout routine is free to arbitrarily set the width
or height if the corresponding variables <w_changeable> and
<h_changeable> are set True. Otherwise the original width or
height in <w_ptr> and <h_ptr> are used as fixed values. The
resulting new width and height are stored back through the
<w_ptr> and <h_ptr> pointers. False is returned if no size
change was done, True is returned otherwise.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static Boolean Layout (MultiListWidget mlw,
Boolean w_changeable,
Boolean h_changeable,
Dimension *w_ptr,
Dimension *h_ptr)
#else
static Boolean Layout (mlw, w_changeable, h_changeable, w_ptr, h_ptr)
MultiListWidget mlw;
Boolean w_changeable;
Boolean h_changeable;
Dimension *w_ptr;
Dimension *h_ptr;
#endif
{
Boolean size_changed;
Dimension primitive_border;
Dimension tw = 0;
int arraysize = 0;
primitive_border = 2 * ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/*
* If force columns is set, then always use the number
* of columns specified by default_cols.
*/
MultiListColWidth(mlw) = MultiListLongest(mlw) + MultiListColumnSpace(mlw);
MultiListRowHeight(mlw) = FontH(MultiListFont(mlw)) + MultiListRowSpace(mlw);
if (MultiListForceCols(mlw))
{
MultiListNumCols(mlw) = max(MultiListDefaultCols(mlw),1);
if (MultiListNumItems(mlw) == 0)
MultiListNumRows(mlw) = 1;
else
MultiListNumRows(mlw) = (MultiListNumItems(mlw) - 1) /
MultiListNumCols(mlw) + 1;
if (w_changeable)
{
if ((arraysize = NumColumnWidths (mlw)) == 0)
*w_ptr = MultiListNumCols(mlw) * MultiListColWidth(mlw) + primitive_border ;
else {
tw = TotalWidth (mlw, MultiListNumCols (mlw));
*w_ptr = tw + primitive_border;
}
size_changed = True;
}
else
{
MultiListColWidth(mlw) = (int)(*w_ptr - primitive_border) / MultiListNumCols(mlw);
}
if (h_changeable)
{
*h_ptr = MultiListNumRows(mlw) * MultiListRowHeight(mlw) + primitive_border;
size_changed = True;
}
return(size_changed);
}
/*
* If both width and height are free to change then use
* default_cols to determine the number of columns and set
* the new width and height to just fit the window.
*/
if (w_changeable && h_changeable)
{
MultiListNumCols(mlw) = max(MultiListDefaultCols(mlw),1);
if (MultiListNumItems(mlw) == 0)
MultiListNumRows(mlw) = 1;
else
MultiListNumRows(mlw) = (MultiListNumItems(mlw) - 1) /
MultiListNumCols(mlw) + 1;
if ((arraysize = NumColumnWidths (mlw)) == 0)
*w_ptr = MultiListNumCols(mlw) * MultiListColWidth(mlw) + primitive_border;
else {
tw = TotalWidth (mlw, MultiListNumCols (mlw));
*w_ptr = tw + primitive_border;
}
*h_ptr = MultiListNumRows(mlw) * MultiListRowHeight(mlw) + primitive_border;
return(True);
}
/*
* If the width is fixed then use it to determine the
* number of columns. If the height is free to move
* (width still fixed) then resize the height of the
* widget to fit the current MultiList exactly.
*/
if (!w_changeable)
{
MultiListNumCols(mlw) = (int)(*w_ptr - primitive_border)/ (int)MultiListColWidth(mlw);
MultiListNumCols(mlw) = max(MultiListNumCols(mlw),1);
MultiListNumRows(mlw) = (MultiListNumItems(mlw) - 1) /
MultiListNumCols(mlw) + 1;
MultiListColWidth(mlw) = (int)(*w_ptr - primitive_border) / MultiListNumCols(mlw);
if (h_changeable)
{
*h_ptr = MultiListNumRows(mlw) * MultiListRowHeight(mlw) + primitive_border;
size_changed = True;
}
return(size_changed);
}
/*
* The last case is xfree and !yfree we use the height to
* determine the number of rows and then set the width to
* just fit the resulting number of columns.
*/
if (!h_changeable)
{
MultiListNumRows(mlw) = (int) (*h_ptr - primitive_border) / (int) MultiListRowHeight(mlw);
MultiListNumRows(mlw) = max(MultiListNumRows(mlw),1);
MultiListNumCols(mlw) = (MultiListNumItems(mlw) - 1) /
MultiListNumRows(mlw) + 1;
*w_ptr = MultiListNumCols(mlw) * MultiListColWidth(mlw) + primitive_border;
return(True);
}
return(size_changed);
} /* End Layout */
/*===========================================================================*
S C R O L L B A R S T U F F
*===========================================================================*/
/*---------------------------------------------------------------------------*
MultiListVertSliderMove( w ,closure, call_data)
Callback for the sliderMoved resource of the vertical scrollbar.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListVertSliderMove (Widget w, caddr_t closure,
XmScrollBarCallbackStruct *call_data)
#else
static void MultiListVertSliderMove (w, closure, call_data)
Widget w;
caddr_t closure;
XmScrollBarCallbackStruct *call_data;
#endif
{
MultiListWidget mlw;
int value;
mlw = (MultiListWidget) (((XmScrolledWindowWidget)w->core.parent)->swindow.WorkWindow);
value = call_data->value ;
/* mlw->multiList.pixel_offset = value; */
#ifdef DEBUG
/* printf("value = %d\n",value); */
#endif
MultiListScroll(mlw, value);
} /* End MultiListVertSliderMove */
/*---------------------------------------------------------------------------*
MultiListSetVerticalScrollbar(mlw)
Set up on an item basis. Min is 0, max is number of rows, origin is
top_position, extent is number of visible item.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListSetVerticalScrollbar (MultiListWidget mlw)
#else
static void MultiListSetVerticalScrollbar (mlw)
MultiListWidget mlw;
#endif
{
int vis_part; /* visible part in pixels */
int max_height, value; /* setup scrollBar */
if (mlw->multiList.vscrollBar == NULL)
return;
/* this will be XmNsliderSize */
vis_part = MultiListHeight(mlw) - 2 * ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/* this will be XmNmaximum */
max_height = MultiListRowHeight(mlw) * MultiListNumRows(mlw);
max_height = max (max_height, vis_part);
/* setup the scrollbar value, we have to check that
XmNvalue + XmNsliderSize <= XmNmaximum
*/
if ( mlw->multiList.pixel_offset > (max_height - vis_part))
{
value = max_height - vis_part;
mlw->multiList.pixel_offset = value;
}
else
value = mlw->multiList.pixel_offset;
XtVaSetValues(mlw->multiList.vscrollBar,
XmNminimum, 0,
XmNmaximum, max_height,
XmNsliderSize, max(1,vis_part),
XmNincrement, MultiListRowHeight(mlw),
XmNpageIncrement, max(1,vis_part),
XmNvalue, value,
NULL);
} /* End MultiListSetVerticalScrollbar */
/*===========================================================================*
P R I M I T I V E R E D R A W R O U T I N E S
*===========================================================================*/
/*---------------------------------------------------------------------------*
MultiListDrawShadow(mlw)
This routine redraw a Motif primitive shadaw in the
MultiList widget <mlw>.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListDrawShadow (MultiListWidget mlw, Boolean armed)
#else
static void MultiListDrawShadow (mlw, armed)
MultiListWidget mlw;
Boolean armed;
#endif
{
if (mlw->primitive.shadow_thickness > 0)
_XmDrawShadow (XtDisplay (mlw), XtWindow (mlw),
(armed
? mlw -> primitive.bottom_shadow_GC
: mlw -> primitive.top_shadow_GC),
(armed
? mlw -> primitive.top_shadow_GC
: mlw -> primitive.bottom_shadow_GC),
mlw -> primitive.shadow_thickness,
mlw -> primitive.highlight_thickness,
mlw -> primitive.highlight_thickness,
mlw -> core.width - 2 * mlw->primitive.highlight_thickness,
mlw -> core.height - 2 *mlw->primitive.highlight_thickness);
}
/*---------------------------------------------------------------------------*
MultiListSetClipRect(mlw)
This routine set a clipping rectangle for the visible area of the
MultiList widget <mlw> and will mark that a clip rectangle is set
with the boolean MultiListClipSet(mlw).
This fonction is called in RedrawRowColumn().
The clip rectangle is reset in the MultiListUnsetClipRect() fonction.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListSetClipRect (MultiListWidget mlw)
#else
static void MultiListSetClipRect (mlw)
MultiListWidget mlw;
#endif
{
int primitive_border;
register Position x,y;
Dimension w,h;
XRectangle rect;
int i = 0;
if(MultiListClipSet(mlw))
return;
primitive_border = mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness;
x = primitive_border;
y = primitive_border;
w = mlw->core.width - (2 * primitive_border);
h = mlw->core.height - (2 * primitive_border);
rect.x = 0;
rect.y = 0;
rect.width = w;
rect.height = h;
if (MultiListEraseGC(mlw))
XSetClipRectangles(XtDisplay(mlw), MultiListEraseGC(mlw), x, y,
&rect, 1, Unsorted);
if (MultiListDrawGC(mlw))
XSetClipRectangles(XtDisplay(mlw), MultiListDrawGC(mlw), x, y,
&rect, 1, Unsorted);
if (MultiListSepGC(mlw))
XSetClipRectangles(XtDisplay(mlw), MultiListSepGC(mlw), x, y,
&rect, 1, Unsorted);
if (MultiListHighlightForeGC(mlw))
XSetClipRectangles(XtDisplay(mlw), MultiListHighlightForeGC(mlw), x, y,
&rect, 1, Unsorted);
if (MultiListHighlightBackGC(mlw))
XSetClipRectangles(XtDisplay(mlw), MultiListHighlightBackGC(mlw), x, y,
&rect, 1, Unsorted);
if (MultiListGrayGC(mlw))
XSetClipRectangles(XtDisplay(mlw), MultiListGrayGC(mlw), x, y,
&rect, 1, Unsorted);
for (i = 0; i < 8; i++)
if (MultiListAltFgGC(mlw, i))
XSetClipRectangles(XtDisplay(mlw), MultiListAltFgGC(mlw, i), x, y,
&rect, 1, Unsorted);
MultiListClipSet(mlw) = True;
}
/*---------------------------------------------------------------------------*
MultiListUnsetClipRect(mlw)
This routine unset a clipping rectangle.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListUnsetClipRect (MultiListWidget mlw)
#else
static void MultiListUnsetClipRect (mlw)
MultiListWidget mlw;
#endif
{
int i = 0;
if(!MultiListClipSet(mlw))
return;
if (MultiListEraseGC(mlw))
XSetClipMask(XtDisplay(mlw), MultiListEraseGC(mlw), None);
if (MultiListDrawGC(mlw))
XSetClipMask(XtDisplay(mlw), MultiListDrawGC(mlw), None);
if (MultiListSepGC(mlw))
XSetClipMask(XtDisplay(mlw), MultiListSepGC(mlw), None);
if (MultiListHighlightForeGC(mlw))
XSetClipMask(XtDisplay(mlw), MultiListHighlightForeGC(mlw), None);
if (MultiListHighlightBackGC(mlw))
XSetClipMask(XtDisplay(mlw), MultiListHighlightBackGC(mlw), None);
if (MultiListGrayGC(mlw))
XSetClipMask(XtDisplay(mlw), MultiListGrayGC(mlw), None);
for (i = 0; i < 8; i++)
if (MultiListAltFgGC(mlw, i))
XSetClipMask(XtDisplay(mlw), MultiListAltFgGC(mlw, i), None);
MultiListClipSet(mlw) = False;
}
/*===========================================================================*
R E D R A W R O U T I N E S
*===========================================================================*/
/*---------------------------------------------------------------------------*
RedrawAll(mlw)
This routine simple calls Redisplay to redraw the entire
MultiList widget <mlw>.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void RedrawAll (MultiListWidget mlw)
#else
static void RedrawAll (mlw)
MultiListWidget mlw;
#endif
{
Redisplay(mlw,NULL,NULL);
} /* End RedrawAll */
/*---------------------------------------------------------------------------*
MultiListRefresh (Widget w)
This routine simple calls Redisplay to redraw the entire
MultiList widget <mlw>.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListRefresh (Widget w)
#else
void MultiListRefresh (w)
Widget w;
#endif
{
MultiListWidget mlw = (MultiListWidget)w;
Redisplay(mlw,NULL,NULL);
}
/*---------------------------------------------------------------------------*
RedrawItem(mlw,item_index)
This routine redraws the item with index <item_index> in the
MultiList widget <mlw>. If the item number is bad, nothing is drawn.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void RedrawItem (MultiListWidget mlw, int item_index)
#else
static void RedrawItem (mlw, item_index)
MultiListWidget mlw;
int item_index;
#endif
{
int row,column;
if ( MultiListItemIsVisible( (Widget)mlw,item_index) == MULTILIST_NO)
return;
if (ItemToRowColumn(mlw,item_index,&row,&column))
{
RedrawRowColumn(mlw,row,column);
}
} /* End RedrawItem */
/*---------------------------------------------------------------------------*
MultiListScroll(mlw, offset)
This routine redraw the MultiList widget using offset to simulate
XtMoveWidget. The offset value is in pixel and comes from scrollbar
value.
When the redraw is finished, we store the new offset in pixel_offset
part of MultiList widget. We do this because we need to use the old
offset value to do an XCopyArea.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListScroll (MultiListWidget mlw, int offset)
#else
static void MultiListScroll (mlw, offset)
MultiListWidget mlw;
int offset;
#endif
{
int delta; /* difference between offset and old offset */
int primitive_border;
int x,h,w,y1,y2,y3;
delta = mlw->multiList.pixel_offset - offset ;
/* now save the offset value to the MultiList widget */
mlw->multiList.pixel_offset = offset;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
x = primitive_border;
w = MultiListWidth(mlw) - 2 * primitive_border;
h = MultiListHeight(mlw) - 2 * primitive_border;
if ( abs(delta) > h )
{
/* we are scrolling more than MultiList height
so we dont need to move area
*/
y3 = primitive_border;
delta = h;
}
else
{
if ( delta < 0 )
{
/* we are scrolling down the ScrollBar, we have to
- move the bottom area up delta pixels,
- redraw the bottom part of the multiList widget
of delta pixels height.
*/
delta = -delta;
y1 = primitive_border + delta; /* source for XCopyArea */
y2 = primitive_border; /* destination for XCopyArea */
y3 = primitive_border + h - delta; /* pos of the area to refresh */
} else
{
/* we are scrolling up */
y1 = primitive_border; /* source for XCopyArea */
y2 = primitive_border + delta ; /* destination for XCopyArea */
y3 = primitive_border; /* pos of the area to refresh */
}
/* now we have to move the area */
XCopyArea(XtDisplay(mlw),XtWindow(mlw),
XtWindow(mlw),
MultiListDrawGC(mlw),
x,
y1,
w,
h - delta,
x,
y2
);
} /* else if abs(delta) > h */
/* and now refresh the new area */
MultiListRedrawArea(mlw,x,y3,w,delta);
} /* End MultiListScroll */
/*---------------------------------------------------------------------------*
MultiListRedrawArea(mlw, x,y,width,height)
This routine redraw the MultiList widget area
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListRedrawArea (MultiListWidget mlw,
int x1, int y1, int w, int h)
#else
static void MultiListRedrawArea (mlw, x1, y1, w, h)
MultiListWidget mlw;
int x1;
int y1;
int w;
int h;
#endif
{
int primitive_border;
int x2,y2,row,col,ul_row,ul_col,lr_row,lr_col;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
x2 = x1 + w;
y2 = y1 + h;
MultiListSetClipRect(mlw);
XFillRectangle(XtDisplay(mlw),XtWindow(mlw),MultiListEraseGC(mlw),
x1,y1,w,h);
if ( MultiListNumItems(mlw) == 0 ) {
PixelToRowColumn(mlw,x1,y1,&ul_row,&ul_col);
PixelToRowColumn(mlw,x2,y2,&lr_row,&lr_col);
#ifdef DEBUG
printf ("MultiListRedrawArea : %d %d\n",ul_row,lr_row);
#endif
lr_row = min(lr_row,MultiListNumRows(mlw) - 1);
lr_col = min(lr_col,MultiListNumCols(mlw) - 1);
for (col = ul_col; col <= lr_col; col++)
{
if (y1 - primitive_border < 0)
y1 = primitive_border;
if (y2 > MultiListHeight(mlw) - primitive_border)
y2 = MultiListHeight(mlw) - primitive_border;
MultiListDrawSeparator (mlw, col, y1, y2);
}
MultiListUnsetClipRect(mlw);
return;
}
PixelToRowColumn(mlw,x1,y1,&ul_row,&ul_col);
PixelToRowColumn(mlw,x2,y2,&lr_row,&lr_col);
#ifdef DEBUG
/* printf ("MultiListRedrawArea : %d %d\n",ul_row,lr_row); */
#endif
lr_row = min(lr_row,MultiListNumRows(mlw) - 1);
lr_col = min(lr_col,MultiListNumCols(mlw) - 1);
for (col = ul_col; col <= lr_col; col++)
{
if (y1 - primitive_border < 0)
y1 = primitive_border;
if (y2 > MultiListHeight(mlw) - primitive_border)
y2 = MultiListHeight(mlw) - primitive_border;
MultiListDrawSeparator (mlw, col, y1, y2);
for (row = ul_row; row <= lr_row; row++)
{
RedrawRowColumn(mlw,row,col);
}
}
MultiListUnsetClipRect(mlw);
} /* End MultiListRedrawArea */
/*---------------------------------------------------------------------------*
MultiListRefreshArea(mlw, x,y,width,height)
This routine redraw the MultiList widget area using blinking feature.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListRefreshArea (MultiListWidget mlw,
int x1, int y1, int w, int h)
#else
static void MultiListRefreshArea (mlw, x1, y1, w, h)
MultiListWidget mlw;
int x1;
int y1;
int w;
int h;
#endif
{
int x2,y2,row,col,ul_row,ul_col,lr_row,lr_col;
int item_index;
Boolean has_item;
MultiListItem *item;
if (mlw->multiList.blink == False)
return;
x2 = x1 + w;
y2 = y1 + h;
#ifdef DEBUG
/* printf ("MultiListRefreshArea : %d %d\n",ul_row,lr_row); */
#endif
MultiListSetClipRect(mlw);
PixelToRowColumn(mlw,x1,y1,&ul_row,&ul_col);
PixelToRowColumn(mlw,x2,y2,&lr_row,&lr_col);
lr_row = min(lr_row,MultiListNumRows(mlw) - 1);
lr_col = min(lr_col,MultiListNumCols(mlw) - 1);
for (col = ul_col; col <= lr_col; col++)
{
for (row = ul_row; row <= lr_row; row++)
{
has_item = RowColumnToItem(mlw,row,col,&item_index);
if (has_item)
{
item = MultiListNthItem(mlw,item_index);
if(MultiListItemBlinking(item) == True)
RedrawRowColumn(mlw,row,col);
}
}
}
MultiListUnsetClipRect(mlw);
} /* End MultiListRefreshArea */
/*---------------------------------------------------------------------------*
RedrawRowColumn(mlw,row,column)
This routine paints the item in row/column position <row>,<column>
on the MultiList widget <mlw>. If the row/column coordinates are
outside the widget, nothing is drawn. If the position is empty,
blank space is drawn.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void RedrawRowColumn (MultiListWidget mlw, int row, int column)
#else
static void RedrawRowColumn (mlw, row, column)
MultiListWidget mlw;
int row;
int column;
#endif
{
GC bg_gc,fg_gc, exchange_gc;
MultiListItem *item;
int ul_x,ul_y,str_x,str_y,w,h,item_index,has_item,text_h;
Boolean draw_string = True ; /* used with blinking */
int i = 0;
int dw;
if (!XtIsRealized((Widget)mlw)) return;
has_item = RowColumnToItem(mlw,row,column,&item_index);
RowColumnToPixels(mlw,row,column,&ul_x,&ul_y,&w,&h);
if (has_item == False) /* No Item */
{
bg_gc = MultiListEraseGC(mlw);
}
else
{
item = MultiListNthItem(mlw,item_index);
if (!MultiListItemSensitive(item) ||
!MultiListSensitive(mlw)) /* Disabled */
{
bg_gc = MultiListEraseGC(mlw);
fg_gc = MultiListGrayGC(mlw);
}
else if (MultiListItemHighlighted(item)) /* Selected */
{
bg_gc = MultiListHighlightBackGC(mlw);
fg_gc = MultiListHighlightForeGC(mlw);
}
else if (MultiListItemFgIndex(item) >= 0 &&
MultiListItemFgIndex(item) < 8)
{
i = MultiListItemFgIndex(item);
bg_gc = MultiListEraseGC(mlw);
fg_gc = MultiListAltFgGC(mlw, i);
}
else /* Normal */
{
bg_gc = MultiListEraseGC(mlw);
fg_gc = MultiListDrawGC(mlw);
}
if( ( mlw->multiList.blink ) &&
(MultiListItemBlinking(item)) &&
(mlw->multiList.blink_on == True))
{
if (mlw->multiList.reverse_video)
{
/* exchange foreground and background GC */
exchange_gc = bg_gc;
bg_gc = fg_gc; fg_gc = exchange_gc;
} else
{
/* set foreground = background */
fg_gc = bg_gc;
draw_string = False;
}
}
}
XFillRectangle(XtDisplay(mlw),XtWindow(mlw),bg_gc,ul_x,ul_y,w,h);
if ((has_item == True) && (draw_string == True) &&
(MultiListItemString(item) != NULL)) {
if (MultiListAlignment(mlw) == XmALIGNMENT_BEGINNING)
str_x = ul_x + MultiListColumnSpace(mlw) / 2;
else if (MultiListAlignment(mlw) == XmALIGNMENT_CENTER) {
dw = w - FontW(MultiListFont(mlw),MultiListItemString(item)) -
MultiListColumnSpace(mlw);
if (dw < 0)
dw = 0;
str_x = ul_x + MultiListColumnSpace(mlw)/2 + dw/2;
}
else {
dw = FontW(MultiListFont(mlw),MultiListItemString(item));
if (dw + MultiListColumnSpace(mlw) > w) /* list too long */
str_x = ul_x + MultiListColumnSpace(mlw) / 2;
else
str_x = ul_x + MultiListColumnSpace(mlw) / 2 +
(w - dw - MultiListColumnSpace(mlw));
}
text_h = min((int) (FontH(MultiListFont(mlw)) + MultiListRowSpace(mlw)),
(int) MultiListRowHeight(mlw));
str_y = ul_y + FontAscent(MultiListFont(mlw)) +
(int) (MultiListRowHeight(mlw) - text_h) / 2;
XDrawString(XtDisplay(mlw),XtWindow(mlw),fg_gc,
str_x,str_y,MultiListItemString(item),
strlen(MultiListItemString(item)));
}
} /* End RedrawRowColumn */
/*===========================================================================*
I T E M L O C A T I O N R O U T I N E S
*===========================================================================*/
/*---------------------------------------------------------------------------*
void PixelToRowColumn(mlw,x,y,row_ptr,column_ptr)
This routine takes pixel coordinates <x>, <y> and converts
the pixel coordinate into a row/column coordinate. This row/column
coordinate can then easily be converted into the specific item
in the list via the function RowColumnToItem().
If the pixel lies in blank space outside of the items, the
row & column numbers will be outside of the range of normal
row & columns numbers, but will correspond to the row & column
of the item, if an item was actually there.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void PixelToRowColumn (MultiListWidget mlw,
int x, int y,
int *row_ptr, int *column_ptr)
#else
static void PixelToRowColumn (mlw, x, y, row_ptr, column_ptr)
MultiListWidget mlw;
int x;
int y;
int *row_ptr;
int *column_ptr;
#endif
{
int primitive_border;
Dimension* array = 0;
int arraysize = 0;
int i = 0;
Dimension tw = 0;
Dimension ow = 0;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/* if x or y = 0 and primitive_border > 0 we can use max() because
we are computing with signed values.
*/
x = max(primitive_border, x);
y = max(primitive_border, y);
if(MultiListRowHeight(mlw) == 0)
{
*row_ptr = 0;
XtWarning("MultiList widget PixelToRowColumn(): XmNrowHeight = 0");
}
else
*row_ptr = (y - primitive_border + mlw->multiList.pixel_offset) /
(int) MultiListRowHeight(mlw);
if (MultiListColWidth(mlw) == 0)
{
*column_ptr = 0;
XtWarning("MultiList widget PixelToRowColumn(): XmNcolWidth = 0");
}
else {
if ((arraysize = NumColumnWidths (mlw)) == 0)
*column_ptr = (x - primitive_border) / (int)MultiListColWidth(mlw);
else
*column_ptr = ColumnByPixel (mlw, x - primitive_border);
}
} /* End PixelToRowColumn */
/*---------------------------------------------------------------------------*
void RowColumnToPixels(mlw,row,col,x_ptr,y_ptr,w_ptr,h_ptr)
This routine takes a row/column coordinate <row>,<col> and
converts it into the bounding pixel rectangle which is returned.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void RowColumnToPixels (MultiListWidget mlw,
int row, int col,
int *x_ptr, int *y_ptr,
int *w_ptr, int *h_ptr)
#else
static void RowColumnToPixels (mlw, row, col, x_ptr, y_ptr, w_ptr, h_ptr)
MultiListWidget mlw;
int row;
int col;
int *x_ptr;
int *y_ptr;
int *w_ptr;
int *h_ptr;
#endif
{
int primitive_border;
int arraysize;
Dimension* array = 0;
Dimension tw = 0;
Dimension ow = 0;
int i = 0;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
if ((arraysize = NumColumnWidths (mlw)) == 0) {
*x_ptr = col * MultiListColWidth(mlw) + primitive_border;
*w_ptr = MultiListColWidth(mlw);
}
else {
ColumnGeometry (mlw, col, x_ptr, w_ptr);
*x_ptr = *x_ptr + primitive_border;
}
*y_ptr = row * MultiListRowHeight(mlw) + primitive_border - mlw->multiList.pixel_offset;
*h_ptr = MultiListRowHeight(mlw);
} /* End RowColumnToPixels */
/*---------------------------------------------------------------------------*
Boolean RowColumnToItem(mlw,row,column,item_ptr)
This routine takes a row number <row> and a column number <column>
and tries to resolve this row and column into the index of the
item in this position of the MultiList widget <mlw>. The resulting
item index is placed through <item_ptr>. If there is no item at
this location, False is returned, else True is returned.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static Boolean RowColumnToItem (MultiListWidget mlw,
int row, int column,
int *item_ptr)
#else
static Boolean RowColumnToItem (mlw, row, column, item_ptr)
MultiListWidget mlw;
int row;
int column;
int *item_ptr;
#endif
{
register int x_stride,y_stride;
if (row < 0 || row >= MultiListNumRows(mlw) ||
column < 0 || column >= MultiListNumCols(mlw))
{
*item_ptr = -1;
return(False);
}
if (MultiListRowMajor(mlw))
{
x_stride = 1;
y_stride = MultiListNumCols(mlw);
}
else
{
x_stride = MultiListNumRows(mlw);
y_stride = 1;
}
*item_ptr = row * y_stride + column * x_stride;
if (*item_ptr >= MultiListNumItems(mlw))
return(False);
else
return(True);
} /* End RowColumnToItem */
/*---------------------------------------------------------------------------*
Boolean ItemToRowColumn(mlw,item_index,row_ptr,column_ptr)
This routine takes an item number <item_index> and attempts
to convert the index into row and column numbers stored through
<row_ptr> and <column_ptr>. If the item number does not
corespond to a valid item, False is returned, else True is
returned.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static Boolean ItemToRowColumn (MultiListWidget mlw, int item_index,
int *row_ptr, int *column_ptr)
#else
static Boolean ItemToRowColumn (mlw, item_index, row_ptr, column_ptr)
MultiListWidget mlw;
int item_index;
int *row_ptr;
int *column_ptr;
#endif
{
if (item_index < 0 || item_index >= MultiListNumItems(mlw))
{
return(False);
}
if (MultiListRowMajor(mlw))
{
*row_ptr = item_index / MultiListNumCols(mlw);
*column_ptr = item_index % MultiListNumCols(mlw);
}
else
{
*row_ptr = item_index % MultiListNumRows(mlw);
*column_ptr = item_index / MultiListNumRows(mlw);
}
return(True);
} /* End ItemToRowColumn */
/*===========================================================================*
M U L T I - C L I C K P R O C E D U R E S
*===========================================================================*/
/*******************************************************************************
* Routines for handling Multi Clicks
* MultiListIsMultiClickClick() MultiListHandleMultiClick
*
******************************************************************************/
#if defined (__STDC__) && !defined(_NO_PROTO)
static Boolean MultiListIsMultiClick (MultiListWidget mlw ,XEvent * event)
#else
static Boolean MultiListIsMultiClick (mlw, event)
MultiListWidget mlw;
XEvent * event;
#endif
{
Boolean is_multiclick;
/* we increment click number */
MultiListClickNumber(mlw)++;
if((event->xbutton.time - mlw->multiList.last_button_time) < mlw->multiList.click_delay)
{
mlw->multiList.last_button_time = event->xbutton.time;
is_multiclick = TRUE;
}
else
{
is_multiclick = FALSE;
MultiListClickNumber(mlw) = 1;
mlw->multiList.last_button_time = event->xbutton.time;
}
return is_multiclick;
}
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListHandleMultiClick (MultiListWidget mlw, int item_index)
#else
static void MultiListHandleMultiClick (mlw, item_index)
MultiListWidget mlw;
int item_index;
#endif
{
int row,column;
Boolean item_valid;
item_valid = ItemToRowColumn(mlw,item_index,&row,&column);
switch (MultiListClickNumber(mlw))
{
case 0:
case 1:
/* selection of a single item */
MultiListUnhighlightAll( (Widget) mlw);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_SET;
MultiListHighlightItem( (Widget)mlw, item_index);
break;
case 2:
/* selection of a the column under the mouse */
if ( item_valid )
{
MultiListHighlightColumn( (Widget)mlw, column);
}
break;
case 3:
/* selection of max selectable items */
if ( item_valid )
{
MultiListHighlightAll((Widget) mlw);
}
break;
}
}
/*===========================================================================*
E V E N T A C T I O N H A N D L E R S
*===========================================================================*/
/*---------------------------------------------------------------------------*
MultiListSet(mlw,event,params,num_params)
This function sets a single text item in the MultiList. Any previously
selected items will be unselected, even if the user later aborts
the click. The item clicked on will be highlighted, and the
MultiListMostRecentItem(mlw) variable will be set to the item clicked
on if any, or -1 otherwise.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListSet (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListSet (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int item_index,row,column;
Boolean item_valid;
MultiListItem *item;
int x, y1, y2, wd;
int minx, inix, colnum;
PixelToRowColumn(mlw,event->xbutton.x,event->xbutton.y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y)) {
SeparatorGeometry (mlw, event->xbutton.x, event->xbutton.y,
&x, &y1, &y2, &wd);
MultiListEraseSeparator (mlw, x, y1, y2, wd);
/* get aux information for this separator */
SeparatorAuxInfo (mlw, event->xbutton.x, event->xbutton.y,
&colnum, &minx, &inix);
MultiListSepX(mlw) = x;
MultiListSepY1(mlw) = y1;
MultiListSepY2(mlw) = y2;
MultiListSepMinX(mlw) = minx;
MultiListSepIniX(mlw) = inix;
MultiListSepCol(mlw) = colnum;
MultiListMoveSeparator (mlw, x, y1, y2, wd);
/* turn flag of the moving separator */
MultiListMoveSep(mlw) = 1;
return;
}
item_valid = RowColumnToItem(mlw,row,column,&item_index);
item = MultiListNthItem(mlw,item_index);
if (! item_valid) item_index = -1;
if (MultiListUseMultiClick(mlw))
{
/* what is the most recent action */
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_SET;
if(MultiListIsMultiClick(mlw, event))
{
/* this is a MultiClick action */
MultiListHandleMultiClick(mlw, item_index);
}
else
{
/* this is a single click : Highlight the selected item */
MultiListUnhighlightAll( (Widget) mlw);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_SET;
MultiListHighlightItem( (Widget)mlw, item_index);
}
}
else if (!MultiListItemSensitive(item))
return;
else /* no multi-click */
/* this is a simple set action */
MultiListHandleMultiClick(mlw,item_index);
} /* End MultiListSet */
/*---------------------------------------------------------------------------*
MultiListSetMany(mlw,event,params,num_params)
This function sets many text item in the MultiList.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListSetMany (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListSetMany (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int px;
int status,item_index,row,column;
#ifdef DEBUG
/* printf("action SetMany()\n"); */
#endif
click_x = event->xbutton.x;
click_y = event->xbutton.y;
/* check whether we are in the mode of moving separator */
if (MultiListMoveSep(mlw) == 1) {
px = MultiListSepX(mlw);
MultiListMoveSeparator(mlw, px,
MultiListSepY1(mlw), MultiListSepY2(mlw),
MultiListSepWidth(mlw));
px = click_x;
if (px <= MultiListSepMinX(mlw))
px = MultiListSepMinX(mlw) + MultiListSepWidth(mlw);
MultiListSepX(mlw) = px;
MultiListMoveSeparator(mlw, MultiListSepX(mlw),
MultiListSepY1(mlw), MultiListSepY2(mlw),
MultiListSepWidth(mlw));
return;
}
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False) item_index = -1;
MultiListHighlightItem( (Widget) mlw,item_index);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_SET;
MultiListMostRecentItem(mlw) = item_index;
} /* End MultiListSetMany */
/*---------------------------------------------------------------------------*
SetColumn(mlw,event,params,num_params)
This function sets all text items in the column from the MultiList.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListSetColumn (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListSetColumn (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False)
return;
/* do Highlight the Column */
MultiListHighlightColumn( (Widget)mlw,column);
} /* End MultiListSetColumn */
/*---------------------------------------------------------------------------*
MultiListSetAll(mlw,event,params,num_params)
This function sets all text item in the MultiList.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListSetAll (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListSetAll (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
MultiListHighlightAll( (Widget)mlw);
} /* End MultiListSetAll */
/*---------------------------------------------------------------------------*
MultiListSelect(mlw,event,params,num_params)
This function draw a rectangle on the selected item
and call the selectCallback to notify application.
The aim of this callback is to let the application to decide what to
do with the selected item. Do we want to highlight item or to
blink it or ...
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListSelect (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListSelect (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
MultiListSelectStruct select_value;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False)
return;
mlw->multiList.selected_item = item_index;
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_SELECT;
/* this is a (pre)-selection callback */
select_value.action = MULTILIST_ACTION_SELECT;
select_value.item = item_index;
select_value.event= event;
select_value.item_value = MultiListNthItem(mlw,item_index);
XtCallCallbacks((Widget)mlw,XmNselectCallback,(caddr_t)&select_value);
} /* End MultiListSelect */
/*---------------------------------------------------------------------------*
MultiListUnselect(mlw,event,params,num_params)
This function un-draw the rectangle to show item selected
and call the selectCallback to notify application.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListUnselect (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListUnselect (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
MultiListSelectStruct select_value;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False)
return;
mlw->multiList.selected_item = item_index;
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_UNSELECT;
/* this is a (pre)-selection callback */
select_value.action = MULTILIST_ACTION_UNSELECT;
select_value.item = item_index;
select_value.event= event;
select_value.item_value = MultiListNthItem(mlw,item_index);
XtCallCallbacks((Widget)mlw,XmNselectCallback,(caddr_t)&select_value);
} /* End MultiListUnselect */
/*---------------------------------------------------------------------------*
MultiListUnset(mlw,event,params,num_params)
This function sets a single text item in the MultiList. If the item
is already unset, then nothing happens. Otherwise, the item is
unset and the selection array and selection count are updated.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListUnset (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListUnset (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False) item_index = -1;
MultiListUnhighlightItem( (Widget) mlw,item_index);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_UNSET;
MultiListMostRecentItem(mlw) = item_index;
} /* End MultiListUnset */
/*---------------------------------------------------------------------------*
UnsetAll(mlw,event,params,num_params)
This function unsets all text item in the MultiList.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListUnsetAll (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListUnsetAll (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
MultiListUnhighlightAll( (Widget) mlw);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_UNSET_ALL;
MultiListMostRecentItem(mlw) = -1;
} /* End MultiListUnsetAll */
/*---------------------------------------------------------------------------*
UnsetMany(mlw,event,params,num_params)
This function unsets many text item in the MultiList.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListUnsetMany (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListUnsetMany (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if(item_index == MultiListMostRecentItem(mlw)) return;
if (status == False) item_index = -1;
MultiListUnhighlightItem( (Widget) mlw,item_index);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_UNSET;
MultiListMostRecentItem(mlw) = item_index;
} /* End MultiListUnsetMany */
/*---------------------------------------------------------------------------*
Toggle(mlw,event,params,num_params)
This function toggles a text item in the MultiList, while leaving the
other selections intact (up to the allowed number of selections).
The item clicked on will be highlighted, and MultiListMostRecentItem(mlw)
will be set to the item number clicked on, or -1 if no item was clicked
on.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListToggle (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListToggle (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False) item_index = -1;
MultiListMostRecentAct(mlw) = MultiListToggleItem((Widget)mlw,item_index);
MultiListMostRecentItem(mlw) = item_index;
} /* End MultiListToggle */
/*---------------------------------------------------------------------------*
ToggleMany(mlw,event,params,num_params)
This function toggles many text item in the MultiList, while leaving the
other selections intact (up to the allowed number of selections).
The item dragged on will be highlighted, and MultiListMostRecentItem(mlw)
will be set to the item number clicked on, or -1 if no item was clicked
on.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListToggleMany (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListToggleMany (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False) item_index = -1;
if(MultiListMostRecentItem(mlw) != item_index)
MultiListMostRecentAct(mlw) = MultiListToggleItem((Widget)mlw,item_index);
MultiListMostRecentItem(mlw) = item_index;
} /* End MultiListToggleMany */
/*---------------------------------------------------------------------------*
ToggleAll(mlw,event,params,num_params)
This function toggles all text items in the MultiList.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListToggleAll (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListToggleAll (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int i;
MultiListSetClipRect(mlw);
for (i = 0; i < MultiListNumItems(mlw); i++)
{
_MultiListToggleItem(mlw,i);
if (MultiListNumSelected(mlw) == MultiListMaxSelectable(mlw))
break;
}
MultiListUnsetClipRect(mlw);
} /* End MultiListToggleAll */
/*---------------------------------------------------------------------------*
MultiListOpen(mlw,event,params,num_params)
This routine handles the opening (normally double clicking)
of an item. All previous selections will be unselected, the
clicked item will be selected, and the OPEN action will be recorded.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListOpen (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListOpen (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
MultiListUnhighlightAll((Widget)mlw);
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False) item_index = -1;
MultiListHighlightItem((Widget) mlw,item_index);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_OPEN;
MultiListMostRecentItem(mlw) = item_index;
} /* End MultiListOpen */
/*---------------------------------------------------------------------------*
OpenMany(mlw,event,params,num_params)
This routine handles the opening (normally double clicking)
of an item. All previous selections will remain selected,
which is why this routine is called OpenMany. Many selections
can be returned on an Open. The clicked item will be selected,
and the OPEN action will be recorded.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListOpenMany (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListOpenMany (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
int click_x,click_y;
int status,item_index,row,column;
click_x = event->xbutton.x;
click_y = event->xbutton.y;
PixelToRowColumn(mlw,click_x,click_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
status = RowColumnToItem(mlw,row,column,&item_index);
if (status == False) item_index = -1;
MultiListHighlightItem( (Widget) mlw,item_index);
MultiListMostRecentAct(mlw) = MULTILIST_ACTION_OPEN;
MultiListMostRecentItem(mlw) = item_index;
} /* End MultiListOpenMany */
/*---------------------------------------------------------------------------*
MultiListNotify(mlw,event,params,num_params)
This function performs the Notify action, which is what happens
when a user releases a button after clicking on an item. If there
was no item under the click, or if the item was insensitive, then
Notify simply returns. Otherwise, notify notifies the user via
a callback of the current list of selected items.
In addition, if the XtNpasteBuffer resource is true and a valid
sensitive item was clicked on, the name of the last clicked on item
will be placed in the X cut buffer (buf(0)).
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListNotify (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListNotify (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
String string;
int final_x,final_y;
int px;
Boolean item_valid;
int item_index,string_length,row,column;
MultiListReturnStruct ret_value;
MultiListSepMoveStruct movesep_value;
MultiListItem *item;
Dimension* array;
int arraysize, col;
int i;
final_x = event->xbutton.x;
final_y = event->xbutton.y;
/* finish dragging the separator */
if (MultiListMoveSep(mlw) == 1) {
MultiListMoveSeparator (mlw, MultiListSepX(mlw),
MultiListSepY1(mlw), MultiListSepY2(mlw),
MultiListSepWidth(mlw));
px = final_x;
if (px <= MultiListSepMinX(mlw))
px = MultiListSepMinX(mlw) + MultiListSepWidth(mlw);
MultiListSepX(mlw) = px;
MultiListDrawSeparatorT (mlw, MultiListSepX(mlw),
MultiListSepY1(mlw), MultiListSepY2(mlw),
MultiListSepWidth(mlw));
MultiListMoveSep(mlw) = 0;
/* reset array widths */
arraysize = NumColumnWidths (mlw);
array = MultiListPrefWidths (mlw);
col = MultiListSepCol(mlw);
/* calculate new column width */
array[col - 1] = array[col - 1] + px - MultiListSepIniX(mlw);
/* redraw all */
RedrawAll (mlw);
/* call move separator callbacks */
movesep_value.action = MULTILIST_END_MOVING_SEP;
movesep_value.event = event;
movesep_value.num = MultiListDefaultCols (mlw);
movesep_value.widths = array;
XtCallCallbacks((Widget)mlw,XmNsepMoveCallback,&movesep_value);
return;
}
PixelToRowColumn(mlw,final_x,final_y,&row,&column);
if (_PixelInsideSeparator (mlw, event->xbutton.x, event->xbutton.y))
return;
item_valid = RowColumnToItem(mlw,row,column,&item_index);
if ( event->xbutton.window != XtWindow(mlw))
{
/* On vient d'effectuer un relachement du boutton
de la souris en dehors du widget MultiList
*/
MultiListUnhighlightAll( (Widget)mlw);
if (MultiListNotifyUnsets(mlw))
{
ret_value.action = MULTILIST_ACTION_UNSET;
ret_value.item = -1;
ret_value.string = NULL;
ret_value.num_selected = MultiListNumSelected(mlw);
ret_value.selected_items = MultiListSelArray(mlw);
ret_value.item_value = NULL;
XtCallCallbacks((Widget)mlw,XmNcallback,&ret_value);
}
return;
}
if (!item_valid ) return;
item = MultiListNthItem(mlw,item_index);
if (!MultiListItemSensitive(item))
return;
string = MultiListItemString(MultiListNthItem(mlw,item_index));
string_length = strlen(string);
if (MultiListMostRecentAct(mlw) == MULTILIST_ACTION_SET)
{
if (MultiListPaste(mlw))
XStoreBytes(XtDisplay(mlw),string,string_length);
}
if (((MultiListMostRecentAct(mlw) == MULTILIST_ACTION_SET) &&
(MultiListNotifySets(mlw) == True)) ||
((MultiListMostRecentAct(mlw) == MULTILIST_ACTION_UNSET) &&
(MultiListNotifyUnsets(mlw) == True)) ||
((MultiListMostRecentAct(mlw) == MULTILIST_ACTION_OPEN) &&
(MultiListNotifyOpens(mlw) == True)))
{
ret_value.action = MultiListMostRecentAct(mlw);
ret_value.item = MultiListMostRecentItem(mlw); /* which number */
ret_value.string = string;
ret_value.num_selected = MultiListNumSelected(mlw);
ret_value.selected_items = MultiListSelArray(mlw);
ret_value.item_value = item; /* the real value of item */
XtCallCallbacks((Widget)mlw,XmNcallback,(caddr_t)&ret_value);
}
} /* End MultiListNotify */
/*===========================================================================*
U S E R C A L L A B L E U T I L I T Y R O U T I N E S
*===========================================================================*/
/*---------------------------------------------------------------------------*
_MultiListHighlightItem(mlw,item_index)
This is the internal version, with cache to the clip rectangle feature.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void _MultiListHighlightItem (MultiListWidget mlw, int item_index)
#else
static void _MultiListHighlightItem (mlw, item_index)
MultiListWidget mlw;
int item_index;
#endif
{
MultiListItem *item;
if (MultiListMaxSelectable(mlw) == 0) return;
if (item_index < 0 || item_index >= MultiListNumItems(mlw))
{
MultiListMostRecentItem(mlw) = -1;
return;
}
item = MultiListNthItem(mlw,item_index);
if (MultiListItemSensitive(item) == False)
{
/* Marc QUINTON this should be a ressource ! */
/* MultiListUnhighlightAll(mlw); */
return;
}
MultiListMostRecentItem(mlw) = item_index;
if (MultiListItemHighlighted(item) == True) return;
if (MultiListNumSelected(mlw) == MultiListMaxSelectable(mlw))
{
_MultiListUnhighlightItem(mlw,MultiListSelArray(mlw)[0]);
}
MultiListItemHighlighted(item) = True;
MultiListSelArray(mlw)[MultiListNumSelected(mlw)] = item_index;
++ MultiListNumSelected(mlw);
RedrawItem(mlw,item_index);
} /* End _MultiListHighlightItem */
/*---------------------------------------------------------------------------*
MultiListHighlightItem(w,item_index)
This routine selects an item with index <item_index> in the
MultiList widget <mlw>. If a maximum number of selections is specified
and exceeded, the earliest selection will be unselected. If
<item_index> doesn't correspond to an item the most recently
clicked item will be set to -1 and this routine will immediately
return, otherwise the most recently clicked item will be set to the
current item,
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListHighlightItem (Widget w, int item_index)
#else
void MultiListHighlightItem (w, item_index)
Widget w;
int item_index;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListSetClipRect(mlw);
_MultiListHighlightItem(mlw,item_index);
MultiListUnsetClipRect(mlw);
} /* End MultiListHighlightItem */
/*---------------------------------------------------------------------------*
MultiListHighlightAll(w)
This routine highlights all highlightable items in the MultiList
widget <mlw>, up to the maximum number of allowed highlightable
items;
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListHighlightAll (Widget w)
#else
void MultiListHighlightAll (w)
Widget w;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
int i;
MultiListSetClipRect(mlw);
for (i = 0; i < MultiListNumItems(mlw); i++)
{
if (MultiListNumSelected(mlw) == MultiListMaxSelectable(mlw))
break;
_MultiListHighlightItem(mlw,i);
}
MultiListUnsetClipRect(mlw);
} /* End MultiListHighlightAll */
/*---------------------------------------------------------------------------*
MultiListHighlightColumn(w,column)
This routine highlights all highlightable items in the MultiList
widget <mlw>, up to the maximum number of allowed highlightable
items, in the specified column.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROT)
void MultiListHighlightColumn (Widget w, int column)
#else
void MultiListHighlightColumn (w, column)
Widget w;
int column;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
int row, item_number;
Boolean item_valid;
MultiListSetClipRect(mlw);
for (row = 0; row < MultiListNumRows(mlw); row++)
{
if (MultiListNumSelected(mlw) == MultiListMaxSelectable(mlw)) break;
item_valid = RowColumnToItem(mlw,row,column,&item_number);
if ( item_valid )
{
_MultiListHighlightItem(mlw,item_number);
}
}
MultiListUnsetClipRect(mlw);
} /* End MultiListHighlightColumn */
/*---------------------------------------------------------------------------*
_MultiListUnhighlightItem(mlw,item_index)
This is the internal version, with cache to the clip rectangle feature.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void _MultiListUnhighlightItem( MultiListWidget mlw, int item_index)
#else
static void _MultiListUnhighlightItem(mlw,item_index)
MultiListWidget mlw;
int item_index;
#endif
{
int i;
MultiListItem *item;
if (MultiListMaxSelectable(mlw) == 0) return;
if (item_index < 0 || item_index >= MultiListNumItems(mlw)) return;
item = MultiListNthItem(mlw,item_index);
if (MultiListItemHighlighted(item) == False) return;
MultiListItemHighlighted(item) = False;
for (i = 0; i < MultiListNumSelected(mlw); i++)
if (MultiListSelArray(mlw)[i] == item_index) break;
for (i = i + 1; i < MultiListNumSelected(mlw); i++)
MultiListSelArray(mlw)[i - 1] = MultiListSelArray(mlw)[i];
-- MultiListNumSelected(mlw);
RedrawItem(mlw,item_index);
} /* End _MultiListUnhighlightItem */
/*---------------------------------------------------------------------------*
MultiListUnhighlightItem(mlw,item_index)
This routine unselects the item with index <item_index> in the
MultiList widget <mlw>. If <item_index> doesn't correspond to a
selected item, then nothing will happen. Otherwise, the item
is unselected and the selection array and count are updated.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListUnhighlightItem(Widget w, int item_index)
#else
void MultiListUnhighlightItem(w,item_index)
Widget w;
int item_index;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListSetClipRect(mlw);
_MultiListUnhighlightItem(mlw,item_index);
MultiListUnsetClipRect(mlw);
} /* End MultiListUnhighlightItem */
/*---------------------------------------------------------------------------*
MultiListUnhighlightAll(w)
This routine unhighlights all items in the MultiList widget <mlw>.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListUnhighlightAll(Widget w)
#else
void MultiListUnhighlightAll(w)
Widget w;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
int i;
MultiListItem *item;
MultiListSetClipRect(mlw);
for (i = 0; i < MultiListNumItems(mlw); i++)
{
item = MultiListNthItem(mlw,i);
if (MultiListItemHighlighted(item))
_MultiListUnhighlightItem(mlw,i);
}
MultiListNumSelected(mlw) = 0;
MultiListUnsetClipRect(mlw);
} /* End MultiListUnhighlightAll */
/*---------------------------------------------------------------------------*
int _MultiListToggleItem(mlw,item_index)
This routine highlights the item with index <item_index>
This is the internal version, with cache to the clip rectangle feature.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static int _MultiListToggleItem(MultiListWidget mlw,int item_index)
#else
static int _MultiListToggleItem(mlw,item_index)
MultiListWidget mlw;
int item_index;
#endif
{
MultiListItem *item;
if (MultiListMaxSelectable(mlw) == 0) return -1;
if (item_index < 0 || item_index >= MultiListNumItems(mlw)) return -1;
item = MultiListNthItem(mlw,item_index);
if (MultiListItemHighlighted(item))
{
_MultiListUnhighlightItem(mlw,item_index);
return(MULTILIST_ACTION_UNSET);
}
else
{
_MultiListHighlightItem(mlw,item_index);
return(MULTILIST_ACTION_SET);
}
} /* End _MultiListToggleItem */
/*---------------------------------------------------------------------------*
int MultiListToggleItem(w,item_index)
This routine highlights the item with index <item_index>
if it is unhighlighted and unhighlights it if it is already
highlighted. The action performed by the toggle is returned
(MULTILIST_ACTION_SET or MULTILIST_ACTION_UNSET).
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
int MultiListToggleItem(Widget w, int item_index)
#else
int MultiListToggleItem(w,item_index)
Widget w;
int item_index;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
int status;
MultiListSetClipRect(mlw);
status = _MultiListToggleItem(mlw,item_index);
MultiListUnsetClipRect(mlw);
return status;
} /* End MultiListToggleItem */
/*---------------------------------------------------------------------------*
MultiListReturnStruct *MultiListGetHighlighted(w)
This routine takes a MultiList widget <mlw> and returns a
MultiListReturnStruct whose num_selected and selected_items
fields contain the highlight information. The action field
is set to MULTILIST_ACTION_STATUS, and the item_index and string
fields are invalid.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
MultiListReturnStruct *MultiListGetHighlighted(Widget w)
#else
MultiListReturnStruct *MultiListGetHighlighted(w)
Widget w;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListItem *item;
static MultiListReturnStruct ret_value;
ret_value.action = MULTILIST_ACTION_STATUS;
if (MultiListNumSelected(mlw) == 0)
{
ret_value.item = -1;
ret_value.string = NULL;
}
else
{
ret_value.item = MultiListSelArray(mlw)[MultiListNumSelected(mlw) - 1];
item = MultiListNthItem(mlw,ret_value.item);
ret_value.string = MultiListItemString(item);
}
ret_value.num_selected = MultiListNumSelected(mlw);
ret_value.selected_items = MultiListSelArray(mlw);
ret_value.item_value = item;
return(&ret_value);
} /* End MultiListGetHighlighted */
/*---------------------------------------------------------------------------*
Boolean MultiListIsHighlighted(w,item_index)
This routine checks if the item with index <item_index>
is highlighted and returns True or False depending. If
<item_index> is invalid, False is returned.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
Boolean MultiListIsHighlighted(Widget w, int item_index)
#else
Boolean MultiListIsHighlighted(w,item_index)
Widget w;
int item_index;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListItem *item;
if (item_index < 0 || item_index >= MultiListNumItems(mlw)) return(False);
item = MultiListNthItem(mlw,item_index);
return(MultiListItemHighlighted(item));
} /* End MultiListIsHighlighted */
/*---------------------------------------------------------------------------*
Boolean MultiListGetItemInfo(w,item_index,str_ptr,h_ptr,s_ptr, b_ptr)
This routine returns the string, highlight status and
sensitivity information for the item with index <item_index>
via the pointers <str_ptr>, <h_ptr> and <s_ptr>. If the item
index is invalid, False is returned, else True is returned.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
Boolean MultiListGetItemInfo(Widget w,
int item_index,
String *str_ptr,
Boolean *h_ptr,
Boolean *s_ptr,
Boolean *b_ptr,
int *fgindex)
#else
Boolean MultiListGetItemInfo(w,item_index,str_ptr,h_ptr,s_ptr, b_ptr, fgindex)
Widget w;
int item_index;
String *str_ptr;
Boolean *h_ptr,*s_ptr, *b_ptr;
int *fgindex;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListItem *item;
if (item_index < 0 || item_index >= MultiListNumItems(mlw)) return(False);
item = MultiListNthItem(mlw,item_index);
*str_ptr = MultiListItemString(item);
*h_ptr = MultiListItemHighlighted(item);
*s_ptr = MultiListItemSensitive(item);
*b_ptr = MultiListItemBlinking(item);
*fgindex = MultiListItemFgIndex(item);
return(True);
} /* End MultiListGetItemInfo */
/*---------------------------------------------------------------------------*
MultiListSetNewData(w,list,nitems,longest,resize,sensitivity_array)
This routine will set a new set of strings <list> into the
MultiList widget <mlw>. If <resize> is True, the MultiList widget will
try to resize itself.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListSetNewData (Widget w,
String *list, int nitems,
int longest,
Boolean resize, Boolean *sensitivity_array)
#else
void MultiListSetNewData (w, list, nitems, longest, resize, sensitivity_array)
Widget w;
String *list;
int nitems;
int longest;
Boolean resize;
Boolean *sensitivity_array;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
DestroyOldData(mlw);
MultiListList(mlw) = list;
MultiListNumItems(mlw) = max(nitems,0);
MultiListLongest(mlw) = max(longest,0);
MultiListSensitiveArray(mlw) = sensitivity_array;
InitializeNewData(mlw);
RecalcCoords(mlw,resize,resize);
MultiListSetVerticalScrollbar(mlw);
if (XtIsRealized((Widget)mlw)) Redisplay(mlw,NULL,NULL);
} /* End MultiListSetNewData */
/*---------------------------------------------------------------------------*
MultiListCreateScrolledList(parent, name, args, argCount)
This routine will create a list inside of a scrolled window.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
Widget MultiListCreateScrolledList (Widget parent,
char *name,
ArgList args,
int argCount)
#else
Widget MultiListCreateScrolledList (parent, name, args, argCount)
Widget parent;
char *name;
ArgList args;
int argCount;
#endif
{
Widget sw, mlw;
char *s;
s = XtMalloc(strlen(name) + 3); /* Name + NULL + "SW" */
strcpy(s, name);
strcat(s, "SW");
sw = XtVaCreateManagedWidget(s ,
xmScrolledWindowWidgetClass, parent,
XmNscrollingPolicy, XmAPPLICATION_DEFINED,
XmNvisualPolicy, XmVARIABLE,
XmNscrollBarDisplayPolicy, XmSTATIC,
XmNshadowThickness, 0,
NULL);
XtFree(s);
mlw = XtCreateWidget( name, multiListWidgetClass, sw, args, argCount);
return (mlw);
} /* End MultiListCreateScrolledList */
/*---------------------------------------------------------------------------*
MultiListAddItems(w,list,nitems,longest,position,resize,
sensitivity_array)
This routine takes a MultiList widget <mlw> and add new data items.
If the number of items is 0, they will be counted, so the array must
be NULL terminated. If the list of strings is NULL, this is treated
as a list of 0 elements.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListAddItems (Widget w,
String *list,
int nitems,
int longest,
int position,
Boolean resize,
Boolean *sensitivity_array)
#else
void MultiListAddItems (w, list, nitems, longest, position, resize, sensitivity_array)
Widget w;
String *list;
int nitems;
int longest;
int position;
Boolean resize;
Boolean *sensitivity_array;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
register int i;
register MultiListItem *item;
MultiListItem *items;
MultiListItem *from, *to;
int len;
int max_text_width = 0;
int text_width;
String str;
if (position < 0 || position > MultiListNumItems(mlw))
return;
if (nitems == 0) /* Count The Elements */
{
if (list == NULL) /* No elements */
{
/* just return ! */
return;
}
else
{
for (i = 0; list[i] != NULL; i++);
nitems = i;
}
}
if (nitems == 0) /* No Items */
{
/* one more time just return */
return;
}
else
{ /* now we have a non null list of nitems */
/* realloc an new array of items MultiListItem */
items = TypeRealloc(
MultiListItemArray(mlw),
MultiListItem,(nitems+MultiListNumItems(mlw)));
MultiListItemArray(mlw) = items;
/* we move item ptr from position to (position + nitems) */
if (position == MultiListNumItems (mlw)) {
from = MultiListNthItem(mlw,(position));
to = MultiListNthItem(mlw,(position + nitems));
len = (MultiListNumItems(mlw) - position) * sizeof (MultiListItem);
bcopy(from, to, len);
}
/* fill the new items at position */
for (i = 0; i < nitems; i++)
{
item = MultiListNthItem(mlw,(i + position));
if (sensitivity_array == NULL ||
(sensitivity_array[i] == True))
{
MultiListItemSensitive(item) = True;
}
else
{
MultiListItemSensitive(item) = False;
}
MultiListItemString(item) = StrCopy(list[i]);
MultiListItemHighlighted(item) = False;
MultiListItemBlinking(item) = False;
MultiListItemFgIndex(item) = -1;
/* look at the longest item */
if(longest == 0);
{
str = MultiListItemString(item);
text_width = FontW(MultiListFont(mlw),str);
max_text_width = max(max_text_width,text_width);
}
}
} /* else nitems == 0 */
/* set up the number of items in the MultiList */
MultiListNumItems(mlw) += nitems;
/* if longest is 0, we have calculated the new longest item,
so update the value to the widget
else impose the new size of a column in pixels.
*/
if(longest == 0)
MultiListLongest(mlw) = max(max_text_width,MultiListLongest(mlw));
else
MultiListLongest(mlw) = longest;
RecalcCoords(mlw,resize,resize);
MultiListSetVerticalScrollbar(mlw);
if (XtIsRealized((Widget)mlw)) Redisplay(mlw,NULL,NULL);
} /* End MultiListAddItems */
/*---------------------------------------------------------------------------*
MultiListAddItems(w,item, position )
This routine takes a MultiList widget <mlw> and add a single new
data item to the list.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListAddItem (Widget w, String item, int position)
#else
void MultiListAddItem (w, item, position)
Widget w;
String item;
int position;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
if (position < 0 || position > MultiListNumItems(mlw))
return;
/* (mlw,list,nitems,longest,position,resize,sensitivity_array) */
MultiListAddItems( (Widget)mlw, &item, 1, 0, position, False, NULL);
} /* End MultiListAddItem */
/*---------------------------------------------------------------------------*
MultiListDeleteItems(w,position,nitems)
This routine takes a MultiList widget <mlw> and delete nitems
starting at the given position.
The return value is the number of items deleted.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
int MultiListDeleteItems (Widget w, int position, int nitems)
#else
int MultiListDeleteItems (w, position, nitems)
Widget w;
int position;
int nitems;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
register int i;
register MultiListItem *item;
MultiListItem *from, *to;
int len, num_selected;
if (position < 0 || position >= MultiListNumItems(mlw)) return 0;
if (MultiListItemArray(mlw) == NULL)
return 0;
if (nitems < 1)
return 0;
/* check that the item number is not greater than
MultiListNumItems - position
*/
nitems = min(nitems,(MultiListNumItems(mlw) - position));
/* Free items at position */
for (i = 0; i < nitems; i++)
{
item = MultiListNthItem(mlw,(i + position));
if(MultiListItemBlinking(item) == True)
mlw->multiList.num_blinking--;
XtFree(MultiListItemString(item));
}
/* we move items from (position + nitems) to (position) */
from = MultiListNthItem(mlw,(position + nitems));
to = MultiListNthItem(mlw,(position));
len = (MultiListNumItems(mlw) - position - nitems)
*sizeof (MultiListItem);
bcopy(from, to, len);
/* realloc an new array of items MultiListItem */
MultiListItemArray(mlw) = TypeRealloc(
MultiListItemArray(mlw),
MultiListItem,(nitems+MultiListNumItems(mlw)));
/* update the MultiListSelArray of selected items :
the job consist in removing items from position to (position + nitems)
that are referenced in the MultiListSelArray
*/
{
int from, to;
from = to = num_selected = 0;
for ( from = 0; from < MultiListNumSelected(mlw); from++)
{
if (( MultiListSelArray(mlw)[from] >= position) &&
( MultiListSelArray(mlw)[from] < (position + nitems)))
{
/* we are in the interval of deleted items */
/* do not copy item */
} else
if (MultiListSelArray(mlw)[from] < position)
{
/* position is lower than interval of deleted items */
/* copy selected item as is */
MultiListSelArray(mlw)[to] = MultiListSelArray(mlw)[from];
to++; num_selected++;
} else
if (MultiListSelArray(mlw)[from] >= (position + nitems))
{
/* this is an item after the interval of deleted items */
/* move it to the 'to' location and update the index value */
MultiListSelArray(mlw)[to] = MultiListSelArray(mlw)[from] - nitems;
to++; num_selected++;
}
else
XtWarning("widget MultiList : MultiListDeleteItems() we should never go here\n");
} /* for ( from = 0; from < MultiListMaxSelectable(mlw); from++) */
}
/* set up the number of items in the MultiList */
MultiListNumItems(mlw) -= nitems;
/* set up the number of selected items */
MultiListNumSelected(mlw) = num_selected;
RecalcCoords(mlw, False, False);
MultiListSetVerticalScrollbar(mlw);
if (XtIsRealized((Widget)mlw)) Redisplay(mlw,NULL,NULL);
return nitems;
} /* End MultiListDeleteItems */
/*---------------------------------------------------------------------------*
MultiListDeleteItem(w,position)
This routine takes a MultiList widget <mlw> and delete a single item
at the given position.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
int MultiListDeleteItem (Widget w, int position)
#else
int MultiListDeleteItem (w, position)
Widget w;
int position;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
if (position < 0 || position >= MultiListNumItems(mlw)) return -1;
return (MultiListDeleteItems((Widget) mlw,position,1));
} /* End MultiListDeleteItem */
/*---------------------------------------------------------------------------*
MultiListItemIsVisible(mlw, position )
This routine takes a MultiList widget <mlw> and check that the position
is visible
the return value is :
MULTILIST_NO,
MULTILIST_YES,
or MULTILIST_NEARLY
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
int MultiListItemIsVisible (Widget widget, int position)
#else
int MultiListItemIsVisible (widget, position)
Widget widget;
int position;
#endif
{
MultiListWidget mlw = (MultiListWidget) widget;
int row,col,x,y, w, h;
int primitive_border;
Region region;
XRectangle rect;
int return_value;
if ( ! ItemToRowColumn(mlw,position,&row,&col))
/* invalid item */
return False;
/* we need the pixels position of the item */
RowColumnToPixels(mlw, row,col,&x,&y,&w,&h);
/* what is the primitive border */
primitive_border = mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness;
/* we use the region primitives from X Lib */
region = XCreateRegion();
rect.x = primitive_border;
rect.y = primitive_border;
rect.width = MultiListWidth (mlw) - 2 * primitive_border;
rect.height = MultiListHeight(mlw) - 2 * primitive_border;
XUnionRectWithRegion(&rect,region,region);
switch(XRectInRegion(region, x,y,w,h))
{
case RectangleOut:
return_value = MULTILIST_NO;
break;
case RectangleIn:
return_value = MULTILIST_YES;
break;
case RectanglePart:
return_value = MULTILIST_NEARLY;
break;
}
XDestroyRegion(region);
return return_value;
} /* End MultiListPosIsVisible */
/*---------------------------------------------------------------------------*
MultiListItemIsVisibleV(mlw, position )
This routine takes a MultiList widget <mlw> and check that the position
is visible in vertical direction
the return value is :
MULTILIST_NO,
MULTILIST_YES,
or MULTILIST_NEARLY
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
int MultiListItemIsVisibleV(Widget widget, int position)
#else
int MultiListItemIsVisibleV (widget, position)
Widget widget;
int position;
#endif
{
MultiListWidget mlw = (MultiListWidget) widget;
int row,col,x,y, w, h;
int primitive_border;
XRectangle rect;
int return_value;
if ( ! ItemToRowColumn(mlw,position,&row,&col))
/* invalid item */
return False;
/* we need the pixels position of the item */
RowColumnToPixels(mlw, row,col,&x,&y,&w,&h);
/* what is the primitive border */
primitive_border = mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness;
rect.x = primitive_border;
rect.y = primitive_border;
rect.width = MultiListWidth (mlw) - 2 * primitive_border;
rect.height = MultiListHeight(mlw) - 2 * primitive_border;
if (y + h <= rect.y + rect.height)
return_value = MULTILIST_YES;
else
return_value = MULTILIST_NO;
return return_value;
} /* End MultiListPosIsVisible */
/*---------------------------------------------------------------------------*
MultiListSetPos(w,position)
This routine takes a MultiList widget <mlw> and makes the item at the
given position the fisrt visible position in the list.
This routine will manage the MultiList widget to insure that the
item designated by position is visible. If it is possible, this item
will be placed on the first row.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListSetPos (Widget w, int position)
#else
void MultiListSetPos (w, position)
Widget w;
int position;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
int foo, row,col,x,y;
int primitive_border;
int old_offset;
Boolean valid;
int total_height;
int vis_part; /* visible part in pixels */
valid = ItemToRowColumn(mlw,position,&row,&col);
if (! valid )
return;
/* first we do this to be able to use the RowColumnToPixels function */
old_offset = mlw->multiList.pixel_offset;
mlw->multiList.pixel_offset = 0;
/* the new offset is in y */
RowColumnToPixels(mlw, row,col,&x,&y,&foo,&foo);
/* restore the old pixel offset */
mlw->multiList.pixel_offset = old_offset;
/* add the primitive width */
primitive_border = mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness;
y -= primitive_border;
if( y == old_offset )
/* we are already at the position specified by position */
return;
total_height = MultiListNumRows(mlw) * MultiListRowHeight(mlw);
vis_part = MultiListHeight(mlw) - 2 * ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/* insure that the new location is coherent with scrollbar */
y = min(y, (total_height - vis_part));
/* do the scrolling operation */
MultiListScroll(mlw, y);
/* update scrollbar */
MultiListSetVerticalScrollbar(mlw);
} /* End MultiListSetPos */
/*---------------------------------------------------------------------------*
MultiListBlinkItem(w,item_index)
This routine takes a MultiList widget <mlw> and makes the item at the
given position blink every blinkDelay ( 500ms is default).
To achieve blinking, we inverse foreground and background.
Selected items are also blinking but at opposite time in comparision
with unselected items.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListBlinkItem (Widget w, int item_index)
#else
void MultiListBlinkItem (w, item_index)
Widget w;
int item_index;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListItem *item;
if (item_index < 0 || item_index >= MultiListNumItems (mlw))
return;
item = MultiListNthItem (mlw, item_index);
if(MultiListItemBlinking(item) == True)
/* the selected item is already blinking ! */
return;
mlw->multiList.num_blinking++;
MultiListItemBlinking (item) = True;
if (mlw->multiList.blink_timer == 0)
{
mlw->multiList.blink_timer =
XtAddTimeOut (mlw->multiList.blink_delay, MultiListBlinkingProc, mlw);
}
}
/*---------------------------------------------------------------------------*
MultiListUnblinkItem(w, item_index )
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListUnblinkItem (Widget w, int item_index)
#else
void MultiListUnblinkItem (w, item_index)
Widget w;
int item_index;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListItem *item;
int row, col;
if (item_index < 0 || item_index >= MultiListNumItems (mlw))
return;
item = MultiListNthItem (mlw, item_index);
if(MultiListItemBlinking(item) == False)
/* the selected item is already 'un'blinking ! */
return;
MultiListItemBlinking (item) = False;
/* force redraw of selected item */
ItemToRowColumn(mlw,item_index,&row,&col);
RedrawRowColumn(mlw,row,col);
mlw->multiList.num_blinking--;
}
/*---------------------------------------------------------------------------*
MultiListBlinkingProc()
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListBlinkingProc (XtPointer client_data, XtIntervalId *id)
#else
static void MultiListBlinkingProc (client_data, id)
XtPointer client_data;
XtIntervalId *id;
#endif
{
MultiListWidget mlw = (MultiListWidget) client_data;
#ifdef DEBUG_1
printf("MultiList %s : nb items = %d, blinking items = %d\n",
XtName(mlw),
MultiListNumItems (mlw), mlw->multiList.num_blinking);
#endif
if ((mlw->multiList.num_blinking == 0))
{
mlw->multiList.blink_timer = 0;
return;
}
MultiListRefreshArea(mlw, 0, 0, mlw->core.width, mlw->core.height);
mlw->multiList.blink_timer=XtAddTimeOut (mlw->multiList.blink_delay, MultiListBlinkingProc, mlw);
/* if blink state was on set it off */
mlw->multiList.blink_on = !mlw->multiList.blink_on;
}
/*---------------------------------------------------------------------------*
int NumColumnWidths (MultiListWidget mlw)
This routine takes a widget and return number of column widths
in the column width array. return 0 if there are none or forceColumn
is not set
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static int NumColumnWidths (MultiListWidget mlw)
#else
static int NumColumnWidths (mlw)
MultiListWidget mlw;
#endif
{
int i = 0;
Dimension *array = NULL;
if (!MultiListForceCols(mlw))
return 0;
if ((array = MultiListPrefWidths (mlw)) == NULL)
return 0;
while (array[i] != 0)
i++;
return i;
}
/*---------------------------------------------------------------------------*
Dimension TotalWidth (MultiListWidget mlw, int numcol)
This routine takes a widget and return total width from left to right
of number of column 'numcol'
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static Dimension TotalWidth (MultiListWidget mlw, int numcol)
#else
static Dimension TotalWidth (mlw, numcol)
MultiListWidget mlw;
int numcol;
#endif
{
Dimension *array = NULL;
Dimension tw = 0;
Dimension ow = 0;
int arraysize = 0;
int i = 0;
arraysize = NumColumnWidths (mlw);
array = MultiListPrefWidths (mlw);
if (arraysize >= numcol) {
for (i = 0; i < numcol; i++)
tw += (array[i] + MultiListSepWidth(mlw) + MultiListColumnSpace(mlw));
}
else {
for (i = 0; i < arraysize; i++) {
ow = array[i] + MultiListSepWidth(mlw) + MultiListColumnSpace(mlw);
tw += ow;
}
for (i = arraysize; i < numcol; i++)
tw += ow;
}
return tw;
}
/*---------------------------------------------------------------------------*
Dimension ColumnWidth (MultiListWidget mlw, int col)
This routine takes a widget and return width of column 'col'
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void ColumnGeometry (MultiListWidget mlw , int col, int *xptr, int* wptr)
#else
static void ColumnGeometry (mlw , col, xptr, wptr)
MultiListWidget mlw;
int col;
int *xptr;
int *wptr;
#endif
{
Dimension* array = NULL;
Dimension tw = 0;
Dimension ow = 0;
int i = 0;
int arraysize = 0;
arraysize = NumColumnWidths (mlw);
array = MultiListPrefWidths (mlw);
if (arraysize >= col)
for (i = 0; i < col; i++) {
tw += (array[i] + MultiListSepWidth(mlw) + MultiListColumnSpace(mlw));
}
else {
for (i = 0; i < arraysize; i++) {
ow = array[i] + MultiListSepWidth(mlw) + MultiListColumnSpace(mlw);
tw += ow;
}
for (i = arraysize; i < col; i++)
tw += ow;
}
*xptr = tw;
/* calculate w_ptr now */
/* column width needs not include sep width and column space*/
if (arraysize >= col + 1)
*wptr = array[col];
else
*wptr = array[arraysize - 1];
}
/*---------------------------------------------------------------------------*
int ColumnByPixel (MultiListWidget mlw, int x)
This routine takes a widget and and X pixel value return column number
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static int ColumnByPixel (MultiListWidget mlw , int x)
#else
static int ColumnByPixel (mlw , x)
MultiListWidget mlw;
int x;
#endif
{
Dimension* array = NULL;
Dimension tw = 0;
Dimension ow = 0;
int i = 0;
int arraysize = 0;
arraysize = NumColumnWidths (mlw);
array = MultiListPrefWidths (mlw);
tw = 0;
if (arraysize >= MultiListDefaultCols (mlw)) {
for (i = 0; i < arraysize; i++) {
tw += (array[i] + MultiListSepWidth(mlw) + MultiListColumnSpace(mlw));
if (x < tw)
return i;
}
}
else {
for (i = 0; i < arraysize; i++) {
ow = array[i] + MultiListSepWidth(mlw) + MultiListColumnSpace(mlw);
tw += ow;
if (x < tw)
return i;
}
for (i = arraysize; i < MultiListDefaultCols (mlw); i++) {
tw += ow;
if (x < tw)
return i;
}
}
}
#if defined (__STDC__) && !defined(_NO_PROTO)
static void _MultiListSetColor (MultiListWidget mlw, int fgindex,
int item_index)
#else
static void _MultiListSetColor (mlw, fgindex, item_index)
MultiListWidget mlw;
int fgindex;
int item_index;
#endif
{
MultiListItem *item;
if (item_index < 0 || item_index >= MultiListNumItems(mlw))
return;
item = MultiListNthItem(mlw,item_index);
/* if already selected, do nothing */
if (MultiListItemHighlighted(item) == True) return;
/* if insensitive, do nothing */
if (MultiListItemSensitive(item) == False)
{
/* Marc QUINTON this should be a ressource ! */
/* MultiListUnhighlightAll(mlw); */
return;
}
/* if already in this index, do nothing */
if (MultiListItemFgIndex(item) == fgindex)
return;
MultiListItemFgIndex(item) = fgindex;
RedrawItem(mlw,item_index);
}
/*---------------------------------------------------------------------------*
MultiListSetColor (mlw, fgindex, item_index)
Set color to item in index 'item_index' with foreground index fgindex
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
/*sergey: to make Darwin happy: static*/ void MultiListSetColor (Widget w, int fgindex,
int item_index)
#else
static void MultiListSetColor (w, fgindex, item_index)
Widget w;
int fgindex;
int item_index;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
MultiListSetClipRect(mlw);
_MultiListSetColor (mlw, fgindex, item_index);
MultiListUnsetClipRect(mlw);
}
/*---------------------------------------------------------------------------*
MultiListSetColorColumn (w, fgindex, column)
This routine set color index in the MultiList
widget in the specified column.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROT)
void MultiListSetColorColumn (Widget w, int fgindex, int column)
#else
void MultiListSetColorColumn (w, fgindex, column)
Widget w;
int fgindex;
int column;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
int row, item_number;
Boolean item_valid;
MultiListSetClipRect(mlw);
for (row = 0; row < MultiListNumRows(mlw); row++)
{
item_valid = RowColumnToItem(mlw,row,column,&item_number);
if ( item_valid )
{
_MultiListSetColor(mlw, fgindex, item_number);
}
}
MultiListUnsetClipRect(mlw);
}
/*---------------------------------------------------------------------------*
MultiListSetColorAll(w, fgindex)
This routine set color to all items in the MultiList
widget <mlw> to color index fgindex
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListSetColorAll (Widget w, int fgindex)
#else
void MultiListSetColorAll (w, fgindex)
Widget w;
int fgindex;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
int i;
MultiListSetClipRect(mlw);
for (i = 0; i < MultiListNumItems(mlw); i++)
_MultiListSetColor (mlw,fgindex, i);
MultiListUnsetClipRect(mlw);
}
/*---------------------------------------------------------------------------*
MultiListAddItemsWithColor(w,list,nitems,longest,position,resize,
sensitivity_array. fgindex)
This routine takes a MultiList widget <mlw> and add new data items.
If the number of items is 0, they will be counted, so the array must
be NULL terminated. If the list of strings is NULL, this is treated
as a list of 0 elements.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListAddItemsWithColor (Widget w,
String *list,
int nitems,
int longest,
int position,
Boolean resize,
Boolean *sensitivity_array,
int fgindex)
#else
void MultiListAddItemsWithColor (w, list, nitems, longest, position,
resize, sensitivity_array, fgindex)
Widget w;
String *list;
int nitems;
int longest;
int position;
Boolean resize;
Boolean *sensitivity_array;
int fgindex;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
register int i;
register MultiListItem *item;
MultiListItem *items;
MultiListItem *from, *to;
int len;
int max_text_width = 0;
int text_width;
String str;
if (position < 0 || position > MultiListNumItems(mlw))
return;
if (nitems == 0) /* Count The Elements */
{
if (list == NULL) /* No elements */
{
/* just return ! */
return;
}
else
{
for (i = 0; list[i] != NULL; i++);
nitems = i;
}
}
if (nitems == 0) /* No Items */
{
/* one more time just return */
return;
}
else
{ /* now we have a non null list of nitems */
/* realloc an new array of items MultiListItem */
items = TypeRealloc(
MultiListItemArray(mlw),
MultiListItem,(nitems+MultiListNumItems(mlw)));
MultiListItemArray(mlw) = items;
/* we move item ptr from position to (position + nitems) */
if (position == MultiListNumItems (mlw)) {
from = MultiListNthItem(mlw,(position));
to = MultiListNthItem(mlw,(position + nitems));
len = (MultiListNumItems(mlw) - position) * sizeof (MultiListItem);
bcopy(from, to, len);
}
/* fill the new items at position */
for (i = 0; i < nitems; i++)
{
item = MultiListNthItem(mlw,(i + position));
if (sensitivity_array == NULL ||
(sensitivity_array[i] == True))
{
MultiListItemSensitive(item) = True;
}
else
{
MultiListItemSensitive(item) = False;
}
MultiListItemString(item) = StrCopy(list[i]);
MultiListItemHighlighted(item) = False;
MultiListItemBlinking(item) = False;
MultiListItemFgIndex(item) = fgindex;
/* look at the longest item */
if(longest == 0);
{
str = MultiListItemString(item);
text_width = FontW(MultiListFont(mlw),str);
max_text_width = max(max_text_width,text_width);
}
}
} /* else nitems == 0 */
/* set up the number of items in the MultiList */
MultiListNumItems(mlw) += nitems;
/* if longest is 0, we have calculated the new longest item,
so update the value to the widget
else impose the new size of a column in pixels.
*/
if(longest == 0)
MultiListLongest(mlw) = max(max_text_width,MultiListLongest(mlw));
else
MultiListLongest(mlw) = longest;
RecalcCoords(mlw,resize,resize);
MultiListSetVerticalScrollbar(mlw);
if (XtIsRealized((Widget)mlw)) Redisplay(mlw,NULL,NULL);
}
/*---------------------------------------------------------------------------*
MultiListAddItemWithColor(w,item, position )
This routine takes a MultiList widget <mlw> and add a single new
data item to the list.
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
void MultiListAddItemWithColor (Widget w, String item, int position, int fgcolor)
#else
void MultiListAddItemWithColor (w, item, position, fgcolor)
Widget w;
String item;
int position;
int fgcolor;
#endif
{
MultiListWidget mlw = (MultiListWidget) w;
if (position < 0 || position > MultiListNumItems(mlw))
return;
/* (mlw,list,nitems,longest,position,resize,sensitivity_array) */
MultiListAddItemsWithColor ( (Widget)mlw, &item, 1, 0, position, False, NULL, fgcolor);
} /* End MultiListAddItemWithColor */
/*---------------------------------------------------------------------------*
_MultiListEraseSeparator (mlw, x, y1, y2 )
This routine takes a MultiList widget <mlw> and draw separaror
from (x, y1) t0 (x, y2)
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void
_MultiListEraseSeparator(Display *display,
Drawable win,
GC separator_GC,
Position wx,
Position wy,
Dimension wwidth,
Dimension wheight,
Dimension shadowThickness,
Dimension margin,
unsigned char orientation,
unsigned char separator_type)
#else
static void
_MultiListEraseSeparator(display,
win,
separator_GC,
wx,
wy,
wwidth,
wheight,
shadowThickness,
margin,
orientation,
separator_type)
Display *display;
Drawable win;
GC separator_GC;
Position wx;
Position wy;
Dimension wwidth;
Dimension wheight;
Dimension shadowThickness;
Dimension margin;
unsigned char orientation;
unsigned char separator_type;
#endif
{
int x,y;
int x1 = 0,y1 = 0,x2 = 0,y2 = 0,x3 = 0,y3 = 0,x4 = 0,y4 = 0;
int width, height, i;
#ifdef DO_FLUSH
XFlush(display);
#endif
if (orientation == XmHORIZONTAL)
{
x = wx + margin;
y = wy + wheight/2;
width = wwidth - 2 * margin;
if (separator_type == XmDOUBLE_LINE ||
separator_type == XmDOUBLE_DASHED_LINE) {
y2 = y1 = y;
y3 = y4 = y+1;
x3 = x1 = x;
x4 = x2 = x+width;
}
else if (separator_type == XmSHADOW_ETCHED_OUT ||
separator_type == XmSHADOW_ETCHED_IN ||
separator_type == XmSHADOW_ETCHED_IN_DASH ||
separator_type == XmSHADOW_ETCHED_OUT_DASH) {
y2 = y1 = y - shadowThickness/2;
y3 = y4 = y;
x3 = x1 = x;
x4 = x2 = x+width;
}
else
{
x1 = x;
y1 = y;
x2 = x+width;
y2 = y;
}
}
else
{
x = wx + wwidth/2;
y = wy + margin;
height = wheight - 2*margin;
y1 = y+height;
x1 = x;
if (separator_type == XmDOUBLE_LINE ||
separator_type == XmDOUBLE_DASHED_LINE) {
y3 = y1 = y;
y2 = y4 = y+height;
x2 = x1 = x;
x4 = x3 = x+1;
}
else if (separator_type == XmSHADOW_ETCHED_OUT ||
separator_type == XmSHADOW_ETCHED_IN ||
separator_type == XmSHADOW_ETCHED_IN_DASH ||
separator_type == XmSHADOW_ETCHED_OUT_DASH){
y3 = y1 = y;
y2 = y4 = y+height;
x2 = x1 = x - shadowThickness/2;
x4 = x3 = x;
}
else
{
x1 = x;
y1 = y;
x2 = x;
y2 = y+height;
}
}
switch(separator_type)
{
case XmSINGLE_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
break;
case XmSINGLE_DASHED_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
break;
case XmDOUBLE_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
XDrawLine(display, win, separator_GC, x3,y3,x4,y4);
break;
case XmDOUBLE_DASHED_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
XDrawLine(display, win, separator_GC, x3,y3,x4,y4);
break;
case XmSHADOW_ETCHED_IN:
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
}
else {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
}
break;
case XmSHADOW_ETCHED_OUT:
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
else {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
break;
case XmSHADOW_ETCHED_IN_DASH:
XSetLineAttributes(display, separator_GC, 0, LineDoubleDash,
CapButt,JoinMiter);
XSetLineAttributes(display, separator_GC, 0, LineDoubleDash,
CapButt,JoinMiter);
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
}
else {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
}
break;
case XmSHADOW_ETCHED_OUT_DASH:
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
else {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, separator_GC,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
break;
case XmNO_LINE:
break;
default:
XDrawLine(display, win, separator_GC, x,y,x1,y1);
break;
}
}
/*---------------------------------------------------------------------------*
_MultiListDrawSeparator (mlw, x, y1, y2 )
This routine takes a MultiList widget <mlw> and draw separaror
from (x, y1) t0 (x, y2)
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void
_MultiListDrawSeparator(Display *display,
Drawable win,
GC top_gc,
GC bottom_gc,
GC separator_GC,
Position wx,
Position wy,
Dimension wwidth,
Dimension wheight,
Dimension shadowThickness,
Dimension margin,
unsigned char orientation,
unsigned char separator_type)
#else
static void
_MultiListDrawSeparator(display, win, top_gc, bottom_gc, separator_GC,
wx, wy,
wwidth, wheight,
shadowThickness,
margin,
orientation,
separator_type)
Display *display;
Drawable win;
GC top_gc;
GC bottom_gc;
GC separator_GC;
Position wx;
Position wy;
Dimension wwidth;
Dimension wheight;
Dimension shadowThickness;
Dimension margin;
unsigned char orientation;
unsigned char separator_type;
#endif
{
int x,y;
int x1 = 0,y1 = 0,x2 = 0,y2 = 0,x3 = 0,y3 = 0,x4 = 0,y4 = 0;
int width, height, i;
#ifdef DO_FLUSH
XFlush(display);
#endif
if (orientation == XmHORIZONTAL)
{
x = wx + margin;
y = wy + wheight/2;
width = wwidth - 2 * margin;
if (separator_type == XmDOUBLE_LINE ||
separator_type == XmDOUBLE_DASHED_LINE) {
y2 = y1 = y;
y3 = y4 = y+1;
x3 = x1 = x;
x4 = x2 = x+width;
}
else if (separator_type == XmSHADOW_ETCHED_OUT ||
separator_type == XmSHADOW_ETCHED_IN ||
separator_type == XmSHADOW_ETCHED_IN_DASH ||
separator_type == XmSHADOW_ETCHED_OUT_DASH) {
y2 = y1 = y - shadowThickness/2;
y3 = y4 = y;
x3 = x1 = x;
x4 = x2 = x+width;
}
else
{
x1 = x;
y1 = y;
x2 = x+width;
y2 = y;
}
}
else
{
x = wx + wwidth/2;
y = wy + margin;
height = wheight - 2*margin;
y1 = y+height;
x1 = x;
if (separator_type == XmDOUBLE_LINE ||
separator_type == XmDOUBLE_DASHED_LINE) {
y3 = y1 = y;
y2 = y4 = y+height;
x2 = x1 = x;
x4 = x3 = x+1;
}
else if (separator_type == XmSHADOW_ETCHED_OUT ||
separator_type == XmSHADOW_ETCHED_IN ||
separator_type == XmSHADOW_ETCHED_IN_DASH ||
separator_type == XmSHADOW_ETCHED_OUT_DASH){
y3 = y1 = y;
y2 = y4 = y+height;
x2 = x1 = x - shadowThickness/2;
x4 = x3 = x;
}
else
{
x1 = x;
y1 = y;
x2 = x;
y2 = y+height;
}
}
switch(separator_type)
{
case XmSINGLE_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
break;
case XmSINGLE_DASHED_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
break;
case XmDOUBLE_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
XDrawLine(display, win, separator_GC, x3,y3,x4,y4);
break;
case XmDOUBLE_DASHED_LINE:
XDrawLine(display, win, separator_GC, x1,y1,x2,y2);
XDrawLine(display, win, separator_GC, x3,y3,x4,y4);
break;
case XmSHADOW_ETCHED_IN:
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, bottom_gc,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, top_gc,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
}
else {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, bottom_gc,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, top_gc,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
}
break;
case XmSHADOW_ETCHED_OUT:
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, top_gc,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, bottom_gc,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
else {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, top_gc,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, bottom_gc,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
break;
case XmSHADOW_ETCHED_IN_DASH:
XSetLineAttributes(display, top_gc, 0, LineDoubleDash,
CapButt,JoinMiter);
XSetLineAttributes(display, bottom_gc, 0, LineDoubleDash,
CapButt,JoinMiter);
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, bottom_gc,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, top_gc,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
}
else {
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, bottom_gc,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
}
for (i = 0; i < shadowThickness/2; i++) {
XDrawLine(display, win, top_gc,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
}
break;
case XmSHADOW_ETCHED_OUT_DASH:
if (orientation == XmVERTICAL) {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, top_gc,
x1 + i, y1 + (shadowThickness/2 - i - 1),
x2 + i, y2 - (shadowThickness/2 - i - 1));
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, bottom_gc,
x3 + i, y3 + i,
x4 + i, y4 - i);
}
else {
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, top_gc,
x1 + (shadowThickness/2 - i - 1), y1 + i,
x2 - (shadowThickness/2 - i - 1), y2 + i);
for (i = 0; i < shadowThickness/2; i++)
XDrawLine(display, win, bottom_gc,
x3 + i, y3 + i,
x4 - i, y4 + i);
}
break;
case XmNO_LINE:
break;
default:
XDrawLine(display, win, separator_GC, x,y,x1,y1);
break;
}
}
/*---------------------------------------------------------------------------*
MultiListEraseSeparator (mlw, x, y1, y2 )
This routine takes a MultiList widget <mlw> and erase separaror
at x, y1 to y2
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListEraseSeparator (MultiListWidget mlw,
int x,
int y1, int y2, int wd)
#else
static void MultiListEraseSeparator (mlw, x, y1, y2, wd)
MultiListWidget mlw;
int x;
int y1;
int y2;
int wd;
#endif
{
/* if separator width is zero, we will do nothing here */
if (MultiListSepWidth(mlw) == 0)
return;
_MultiListEraseSeparator (XtDisplay(mlw), XtWindow (mlw),
MultiListEraseGC(mlw),
(Position)x,
(Position)y1,
(Dimension)wd,
(Dimension)(y2 - y1),
(Dimension)wd,
0, XmVERTICAL, MultiListSepType(mlw));
}
/*---------------------------------------------------------------------------*
MultiListDrawSeparator (mlw, col, y1, y2 )
This routine takes a MultiList widget <mlw> and draw separaror
at col, y1 to y2
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListDrawSeparator (MultiListWidget mlw,
int col,
int y1, int y2)
#else
static void MultiListDrawSeparator (mlw, col, y1, y2)
MultiListWidget mlw;
int col;
int y1;
int y2;
#endif
{
int colx;
int colw;
/* if separator width is zero, we will do nothing here */
if (MultiListSepWidth(mlw) == 0)
return;
ColumnGeometry (mlw , col + 1, &colx, &colw);
_MultiListDrawSeparator (XtDisplay(mlw), XtWindow (mlw),
MultiListTopShadowGC(mlw),
MultiListBottomShadowGC(mlw),
MultiListSepGC(mlw),
(Position)(colx - MultiListSepWidth(mlw)),
(Position)y1,
(Dimension)(MultiListSepWidth(mlw)),
(Dimension)(y2 - y1),
MultiListSepWidth(mlw),
0, XmVERTICAL, MultiListSepType(mlw));
}
/*---------------------------------------------------------------------------*
MultiListMoveSeparator (mlw, col, y1, y2 )
This routine takes a MultiList widget <mlw> and draw separaror
at col, y1 to y2
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListMoveSeparator (MultiListWidget mlw,
int x,
int y1, int y2, int wd)
#else
static void MultiListMoveSeparator (mlw, x, y1, y2, wd)
MultiListWidget mlw;
int x;
int y1;
int y2;
int wd;
#endif
{
_MultiListDrawSeparator (XtDisplay(mlw), XtWindow (mlw),
MultiListSepGC(mlw),
MultiListSepGC(mlw),
MultiListSepGC(mlw),
(Position)x,
(Position)y1,
(Dimension)wd,
(Dimension)(y2 - y1),
(Dimension)wd,
0, XmVERTICAL, MultiListSepType(mlw));
}
/*---------------------------------------------------------------------------*
MultiListDrawSeparatorT (mlw, col, y1, y2 )
This routine takes a MultiList widget <mlw> and draw separaror
at col, y1 to y2
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListDrawSeparatorT (MultiListWidget mlw,
int x,
int y1, int y2, int wd)
#else
static void MultiListDrawSeparatorT (mlw, x, y1, y2, wd)
MultiListWidget mlw;
int x;
int y1;
int y2;
int wd;
#endif
{
_MultiListDrawSeparator (XtDisplay(mlw), XtWindow (mlw),
MultiListTopShadowGC(mlw),
MultiListBottomShadowGC(mlw),
MultiListSepGC(mlw),
(Position)x,
(Position)y1,
(Dimension)wd,
(Dimension)(y2 - y1),
(Dimension)wd,
0, XmVERTICAL, MultiListSepType(mlw));
}
/*---------------------------------------------------------------------------*
PixelInsideSeparator (x, y)
This routine will check whether a point (x, y) is inside a separator
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static int _PixelInsideSeparator (MultiListWidget mlw,
int x, int y)
#else
static int _PixelInsideSeparator (mlw, x, y)
MultiListWidget mlw;
int x;
int y;
#endif
{
int primitive_border;
int col;
int colx, colw;
/* separator only works with forceColumn true */
if (NumColumnWidths (mlw) == 0 || MultiListSepWidth(mlw) == 0)
return 0;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/* if x or y = 0 and primitive_border > 0 we can use max() because
we are computing with signed values.
*/
x = max(primitive_border, x);
y = max(primitive_border, y);
col = ColumnByPixel (mlw, x - primitive_border);
ColumnGeometry (mlw , col + 1, &colx, &colw);
/* separator starts at colx - sepw */
if (x <= colx && x > colx - MultiListSepWidth(mlw))
return 1;
return 0;
}
/*---------------------------------------------------------------------------*
PixelInsideSeparator (x, y, colptr)
This routine will check whether a point (x, y) is inside a separator
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static int PixelInsideSeparator (MultiListWidget mlw,
int x, int y, int *colptr)
#else
static int PixelInsideSeparator (mlw, x, y, colptr)
MultiListWidget mlw;
int x;
int y;
int *colptr;
#endif
{
int primitive_border;
int colx, colw;
/* separator only works with forceColumn true */
if (NumColumnWidths (mlw) == 0 || MultiListSepWidth(mlw) == 0)
return 0;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/* if x or y = 0 and primitive_border > 0 we can use max() because
we are computing with signed values.
*/
x = max(primitive_border, x);
y = max(primitive_border, y);
*colptr = ColumnByPixel (mlw, x - primitive_border);
ColumnGeometry (mlw , *colptr + 1, &colx, &colw);
/* separator starts at colx - sepw/2 */
if (x <= colx && x > colx - MultiListSepWidth(mlw))
return 1;
return 0;
}
/*---------------------------------------------------------------------------*
MultiListTrackPointer (mlw, col, y1, y2 )
This routine takes a MultiList widget <mlw> and draw separaror
at col, y1 to y2
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void MultiListTrackPointer (MultiListWidget mlw,
XEvent *event,
String *params,
Cardinal *num_params)
#else
static void MultiListTrackPointer (mlw, event, params, num_params)
MultiListWidget mlw;
XEvent *event;
String *params;
Cardinal *num_params;
#endif
{
XMotionEvent* mev;
int col;
static int _insep = 0;
/* separator only works with forceColumn true */
if (NumColumnWidths (mlw) == 0 || MultiListSepWidth(mlw) == 0)
return;
mev = (XMotionEvent *)event;
if (PixelInsideSeparator (mlw, mev->x, mev->y, &col)) {
if (!_insep) {
XDefineCursor (XtDisplay (mlw), XtWindow (mlw), MultiListMCursor(mlw));
_insep = 1;
}
}
else {
if (_insep) {
XUndefineCursor (XtDisplay (mlw), XtWindow (mlw));
_insep = 0;
}
}
}
/*---------------------------------------------------------------------------*
SeparatorGeometry (mlw, ex, ey, x, y1, y2, sepw)
This routine takes a MultiList widget <mlw> and return a separator
geometry
This routine is called after insideSeparator has been checked
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void SeparatorGeometry (MultiListWidget mlw,
int ex, int ey,
int *x, int* y1, int *y2, int *sepw)
#else
static void SeparatorGeometry (mlw, ex, ey, x, y1, y2, sepw)
MultiListWidget mlw;
int ex;
int ey;
int *x;
int *y1;
int *y2;
int *sepw;
#endif
{
int primitive_border;
int col;
int colx, colw;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/* if x or y = 0 and primitive_border > 0 we can use max() because
we are computing with signed values.
*/
ex = max(primitive_border, ex);
ey = max(primitive_border, ey);
col = ColumnByPixel (mlw, ex - primitive_border);
ColumnGeometry (mlw , col + 1, &colx, &colw);
*x = colx - MultiListSepWidth(mlw);
*y1 = primitive_border;
*y2 = MultiListHeight(mlw) - primitive_border;
*sepw = MultiListSepWidth(mlw);
}
/*---------------------------------------------------------------------------*
SeparatorAuxInfo (mlw, ex, ey, col, minx, inix)
This routine takes a MultiList widget <mlw> and return a separator
information
This routine is called after insideSeparator has been checked
*---------------------------------------------------------------------------*/
#if defined (__STDC__) && !defined(_NO_PROTO)
static void SeparatorAuxInfo (MultiListWidget mlw,
int ex, int ey,
int *col, int* minx, int* inix)
#else
static void SeparatorAuxInfo (mlw,
ex, ey,
col, minx, inix)
MultiListWidget mlw;
int ex;
int ey;
int *col;
int *minx;
int* inix;
#endif
{
int primitive_border;
int colx, colw;
int tcol;
primitive_border = ( mlw->primitive.shadow_thickness +
mlw->primitive.highlight_thickness);
/* if x or y = 0 and primitive_border > 0 we can use max() because
we are computing with signed values.
*/
ex = max(primitive_border, ex);
ey = max(primitive_border, ey);
tcol = ColumnByPixel (mlw, ex - primitive_border);
/* column at the left of this separator */
ColumnGeometry (mlw , tcol, &colx, &colw);
*minx = colx;
/* current separator's column information */
ColumnGeometry (mlw , tcol + 1, &colx, &colw);
*col = tcol + 1;
*inix = ex;
}
| [
"andrea.celentano@ge.infn.it"
] | andrea.celentano@ge.infn.it |
0ac60ad8433962e004de841d02d22db84e4964fa | fd36795a6092e16cdd374fe8367f0f0617a22ea4 | /src/include/access/persistentendxactrec.h | d8c29ca8c45b465775f06a83e049b5ce8dd14da3 | [
"MIT",
"BSD-4-Clause-UC",
"BSD-3-Clause",
"ISC",
"bzip2-1.0.6",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-4-Clause",
"Artistic-2.0",
"PostgreSQL",
"LicenseRef-scancode-unknown"
] | permissive | DalavanCloud/hawq | eab7d93481173dafb4da42c2d16249310c4c2fc9 | aea301f532079c3a7f1ccf0a452ed79785a1a3a3 | refs/heads/master | 2020-04-29T10:14:22.533820 | 2019-03-15T13:51:53 | 2019-03-16T03:37:51 | 176,054,339 | 1 | 0 | Apache-2.0 | 2019-03-17T04:02:59 | 2019-03-17T04:02:58 | null | UTF-8 | C | false | false | 5,580 | h | /*-------------------------------------------------------------------------
*
* persistentendxactrec.h
* Make and read persistent information in commit, abort, and prepared records.
*
* 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.
*
*-------------------------------------------------------------------------
*/
#ifndef PERSISTENTENDXACTREC_H
#define PERSISTENTENDXACTREC_H
#include "postgres.h"
#include "storage/dbdirnode.h"
#include "storage/relfilenode.h"
#include "storage/itemptr.h"
#include "access/persistentfilesysobjname.h"
/*
* The end of transaction possibilities.
*/
typedef enum EndXactRecKind
{
EndXactRecKind_None = 0,
EndXactRecKind_Commit = 1,
EndXactRecKind_Abort = 2,
EndXactRecKind_Prepare = 3,
MaxEndXactRecKind /* must always be last */
} EndXactRecKind;
/*
* The persistent transaction object possibilities.
*/
typedef enum PersistentEndXactObjKind
{
PersistentEndXactObjKind_None = 0,
PersistentEndXactObjKind_FileSysAction = 1,
PersistentEndXactObjKind_AppendOnlyMirrorResyncEofs = 2,
MaxPersistentEndXactObjKind /* must always be last */
} PersistentEndXactObjKind;
/*
* The persistent transaction object possibilities.
*/
typedef enum PersistentEndXactFileSysAction
{
PersistentEndXactFileSysAction_None = 0,
PersistentEndXactFileSysAction_Create = 1,
PersistentEndXactFileSysAction_Drop = 2,
PersistentEndXactFileSysAction_AbortingCreateNeeded = 3,
MaxPersistentEndXactFileSysAction /* must always be last */
} PersistentEndXactFileSysAction;
static inline bool PersistentEndXactFileSysAction_IsValid(
PersistentEndXactFileSysAction action)
{
return (action >= PersistentEndXactFileSysAction_Create &&
action <= PersistentEndXactFileSysAction_AbortingCreateNeeded);
}
/*
* Structure containing the end transaction information for a relation file.
*/
typedef struct PersistentEndXactFileSysActionInfo
{
PersistentEndXactFileSysAction action;
PersistentFileSysObjName fsObjName;
PersistentFileSysRelStorageMgr relStorageMgr;
ItemPointerData persistentTid;
int64 persistentSerialNum;
} PersistentEndXactFileSysActionInfo;
typedef struct PersistentEndXactAppendOnlyMirrorResyncEofs
{
RelFileNode relFileNode;
int32 segmentFileNum;
ItemPointerData persistentTid;
int64 persistentSerialNum;
int64 mirrorLossEof;
int64 mirrorNewEof;
} PersistentEndXactAppendOnlyMirrorResyncEofs;
typedef struct PeristentEndXaxtUntyped
{
void *data;
int32 len;
int32 count;
} PeristentEndXaxtUntyped;
/*
* Structure containing the objects read.
*/
typedef union PersistentEndXactRecObjects
{
PeristentEndXaxtUntyped untyped[MaxPersistentEndXactObjKind];
struct typed
{
PersistentEndXactFileSysActionInfo *fileSysActionInfos;
int32 fileSysActionInfosLen;
int32 fileSysActionInfosCount;
PersistentEndXactAppendOnlyMirrorResyncEofs *appendOnlyMirrorResyncEofs;
int32 appendOnlyMirrorResyncEofsLen;
int32 appendOnlyMirrorResyncEofsCount;
}typed;
} PersistentEndXactRecObjects;
char *PersistentXactObjKind_Name(
PersistentEndXactObjKind objKind);
extern char *EndXactRecKind_Name(
EndXactRecKind endXactRecKind);
extern bool EndXactRecKind_NeedsAction(
EndXactRecKind endXactRecKind,
PersistentEndXactFileSysAction action);
extern char *PersistentEndXactFileSysAction_Name(
PersistentEndXactFileSysAction action);
extern void PersistentEndXactRec_Init(
PersistentEndXactRecObjects *objects);
extern void PersistentEndXactRec_AddFileSysActionInfos(
PersistentEndXactRecObjects *objects,
EndXactRecKind endXactRecKind,
PersistentEndXactFileSysActionInfo *fileSysActionInfos,
int count);
extern int32 PersistentEndXactRec_FetchObjectsFromSmgr(
PersistentEndXactRecObjects *objects,
EndXactRecKind endXactRecKind,
int16 *objectCount);
extern bool PersistentEndXactRec_WillHaveObjectsFromSmgr(
EndXactRecKind endXactRecKind);
extern void PersistentEndXactRec_Print(
char *procName,
PersistentEndXactRecObjects *objects);
extern int16 PersistentEndXactRec_ObjectCount(
PersistentEndXactRecObjects *objects,
EndXactRecKind endXactRecKind);
extern int32 PersistentEndXactRec_SerializeLen(
PersistentEndXactRecObjects *objects,
EndXactRecKind endXactRecKind);
extern void PersistentEndXactRec_Serialize(
PersistentEndXactRecObjects *objects,
EndXactRecKind endXactRecKind,
int16 *numOfObjects,
uint8 *buffer,
int32 bufferLen);
extern int32 PersistentEndXactRec_DeserializeLen(
uint8 *buffer,
int16 numOfObjects);
extern void PersistentEndXactRec_Deserialize(
uint8 *buffer,
int16 numOfObjects,
PersistentEndXactRecObjects *objects,
uint8 **nextData);
#endif /* PERSISTENTENDXACTREC_H */
| [
"rvs@apache.org"
] | rvs@apache.org |
7853d81d1da214498c1c8dfe68aa5e13de33d289 | d111939ff59748253d99740ed3996121aeb6ce38 | /src_release_GATT/proj/drivers/flash.h | 0befd4009d92e1b8a0506696199e98d65ae630fa | [] | no_license | zhaolaipi/17HXX_OTP_Plug-in_Flash_SDK_Release | 6592065b9327d85c37a6ad0daa598fa3f886154c | c7081bac1a3f8bbdb08908f445644a23a8dc6093 | refs/heads/master | 2022-01-17T20:58:08.863138 | 2019-08-02T08:25:56 | 2019-08-02T08:25:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 655 | h |
#pragma once
#include "../common/types.h"
#include "../mcu/compiler.h"
enum{
FLASH_WRITE_CMD = 0x02,
FLASH_READ_CMD = 0x03,
FLASH_WRITE_ENABLE_CMD = 0x06,
FLASH_WRITE_DISABLE_CMD = 0x04,
FLASH_READ_STATUS_CMD = 0x05,
FLASH_SECT_ERASE_CMD = 0x20,
FLASH_BLK_ERASE_CMD = 0xD8,
FLASH_POWER_DOWN = 0xB9,
FLASH_GET_JEDEC_ID = 0x9F,
};
_attribute_ram_code_ void flash_erase_sector(u32 addr);
_attribute_ram_code_ void flash_erase_block(u32 addr);
_attribute_ram_code_ void flash_write_page(u32 addr, u32 len, u8 *buf);
_attribute_ram_code_ void flash_read_page(u32 addr, u32 len, u8 *buf);
_attribute_ram_code_ u32 flash_get_jedec_id();
| [
"jingyang@lenzetech.com"
] | jingyang@lenzetech.com |
751058dd0f410dc9b7d4d7f664a527a7f13e0e58 | 48998e7c0ab72798ce14061f36261282bb7fbaa5 | /COMPONENTS/SHELL/SHELL.c | 2f0d7d8fc0e0c9923ae0e9035337f6512782059a | [] | no_license | ehughes/eLib | 06fa2ea88d617ae21e0638e733fe8abd32d9305a | 4d7938bc4497d53a26bcc70898c3093a0bdb3456 | refs/heads/master | 2020-12-25T14:14:04.592531 | 2020-05-08T20:42:07 | 2020-05-08T20:42:07 | 66,391,632 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 26,809 | c | #include "nrf.h"
#include "Shell.h"
#include "SHELL_Commands.h"
#include "SHELL_Commands__Application.h"
#include "SHELL_Commands__FileSystem.h"
#include "Shell_Commands__Configuration.h"
#include "SHELL_Commands__Cell.h"
#include "SHELL_Commands__Bridge.h"
#include "SHELL_Commands__Cloud.h"
#include "System.h"
#include "Board.h"
#include "Components/RTT/SEGGER_RTT.h"
#include "system_nrf52840.h"
#include "Drivers/SC16IS741A/SC16IS741A.h"
#define SHELL_SERIAL_TX_QUEUE_SIZE (2048)
#define SHELL_SERIAL_RX_QUEUE_SIZE (2048)
#define CLOUD_SHELL_TX_QUEUE_SIZE (1500)
#define CLOUD_SHELL_RX_QUEUE_SIZE (1024)
shell_context_struct MySerialShell;
shell_context_struct MyCloudShell;
ByteQueue ShellInputQueue;
ByteQueue ShellOutputQueue;
uint8_t ShellInputQueueStorage[SHELL_SERIAL_RX_QUEUE_SIZE];
uint8_t ShellOutputQueueStorage[SHELL_SERIAL_TX_QUEUE_SIZE];
ByteQueue Shell_Uart_OutputQueue;
uint8_t Shell_Uart_OutputQueueStorage[SHELL_SERIAL_TX_QUEUE_SIZE];
uint32_t ShellHasBeenInitialized = 0;
uint8_t ShellTempOutputBuffer[SHELL_SERIAL_TX_QUEUE_SIZE];
uint8_t CloudShellInputQueueStorage[CLOUD_SHELL_TX_QUEUE_SIZE];
uint8_t CloudShellOutputQueueStorage[CLOUD_SHELL_RX_QUEUE_SIZE];
ByteQueue CloudShellInputQueue;
ByteQueue CloudShellOutputQueue;
/*
There is a linker setting in SES to route __putchar to this symbol so we can get printf's out
*/
int my_putchar(int ch)
{
if(ch == '\n')
{
ByteEnqueue(&ShellOutputQueue,'\r');
ByteEnqueue(&ShellOutputQueue,'\n');
}
else
{
ByteEnqueue(&ShellOutputQueue,ch);
}
return EOF;
}
void Init_Shell()
{
Init_Shell_IO();
InitByteQueue(&ShellInputQueue, SHELL_SERIAL_RX_QUEUE_SIZE, ShellInputQueueStorage);
InitByteQueue(&ShellOutputQueue, SHELL_SERIAL_TX_QUEUE_SIZE, ShellOutputQueueStorage);
InitByteQueue(&Shell_Uart_OutputQueue, SHELL_SERIAL_TX_QUEUE_SIZE, Shell_Uart_OutputQueueStorage);
MySerialShell.ShellInQueue = &ShellInputQueue;
MySerialShell.ShellOutQueue = &ShellOutputQueue;
MySerialShell.echo = 0;
MySerialShell.Description = "";
MySerialShell.prompt =">";
MySerialShell.CurrentPrivilegeLevel = 0;
InitByteQueue(&CloudShellInputQueue, CLOUD_SHELL_RX_QUEUE_SIZE, CloudShellInputQueueStorage);
InitByteQueue(&CloudShellOutputQueue, CLOUD_SHELL_TX_QUEUE_SIZE, CloudShellOutputQueueStorage);
MyCloudShell.ShellInQueue = &CloudShellInputQueue;
MyCloudShell.ShellOutQueue = &CloudShellOutputQueue;
MyCloudShell.echo = 0;
MyCloudShell.Description = "Remote Cloud Shell";
MyCloudShell.prompt ="";
MyCloudShell.CurrentPrivilegeLevel = 0;
MyCloudShell.QuietOnBadCommand = 1;
SHELL_RegisterCommand(&MyCloudShell,
"beep",
"Mario Beep",
(cmd_function_t)CloudBeep,
0
);
SHELL_RegisterCommand(&MyCloudShell,
"br",
"retrieves the birth record",
(cmd_function_t)(br),
0
);
SHELL_RegisterCommand(&MyCloudShell,
"cell",
"gets cell modem info",
(cmd_function_t)(cell),
0
);
SHELL_RegisterCommand(&MyCloudShell,
"probe",
"gets the birth records of the probes",
(cmd_function_t)(probe),
0
);
SHELL_RegisterCommand(&MyCloudShell,
"reboot",
"system reboot",
(cmd_function_t)(reset),
0
);
SHELL_RegisterCommand(&MyCloudShell,
"pp",
"probe power",
(cmd_function_t)(pp),
0
);
SHELL_RegisterCommand(&MyCloudShell,
"mget",
"",
(cmd_function_t)(mget),
0
);
SHELL_RegisterCommand(&MyCloudShell,
"mset",
"probe power",
(cmd_function_t)(mset),
0
);
SHELL_RegisterCommand(&MyCloudShell,
"msave",
"probe power",
(cmd_function_t)(msave),
0
);
SHELL_RegisterCommand(&MySerialShell,
"help",
"List all available Commands",
(cmd_function_t)HelpCommand ,
0
);
SHELL_RegisterCommand(&MySerialShell,
"cow",
"it moos",
(cmd_function_t)(cow)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"i",
"Enter interactive mode",
(cmd_function_t)(i)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"q",
"Enter quiet mode",
(cmd_function_t)(q)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"reboot",
"software reset",
(cmd_function_t)(reset),
0
);
SHELL_RegisterCommand(&MySerialShell,
"debug",
"sets the current debug message level",
(cmd_function_t)(debug),
0
);
SHELL_RegisterCommand(&MySerialShell,
"br",
"retrieves the birth record",
(cmd_function_t)(br),
0
);
SHELL_RegisterCommand(&MySerialShell,
"rt",
"forces a resync of internal time",
(cmd_function_t)(rt),
0
);
SHELL_RegisterCommand(&MySerialShell,
"beep",
"mario 11",
(cmd_function_t)(CloudBeep),
0
);
SHELL_RegisterCommand(&MySerialShell,
"shell_test",
"Use this to show the parsed arguments.",
(cmd_function_t)(shell_test)
,0
);
#ifdef eli
SHELL_RegisterCommand(&MySerialShell,
"flash_info",
"Gets the JEDEC Flash codes",
(cmd_function_t)(flash_info) ,
0
);
SHELL_RegisterCommand(&MySerialShell,
"erase_flash",
"erases the entire flash",
(cmd_function_t)(erase_flash) ,
0
);
#endif
SHELL_RegisterCommand(&MySerialShell,
"flash_read",
"reads a flash sector",
(cmd_function_t)(flash_sector_read),
0
);
SHELL_RegisterCommand(&MySerialShell,
"test_flash",
"tests the flash array",
(cmd_function_t)(test_flash),
0
);
SHELL_RegisterCommand(&MySerialShell,
"format",
"formats the internal flash",
(cmd_function_t)(format) ,
0
);
SHELL_RegisterCommand(&MySerialShell,
"ls",
"directory listing",
(cmd_function_t)(ls),
0
);
SHELL_RegisterCommand(&MySerialShell,
"touch",
"creates a file",
(cmd_function_t)(touch),
0
);
SHELL_RegisterCommand(&MySerialShell,
"rm",
"deletes a file",
(cmd_function_t)(touch)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"test_fs",
"tests the file system",
(cmd_function_t)(test_fs)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"more",
"dumps a text file",
(cmd_function_t)(more)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"check_fs",
"checks the flash file system",
(cmd_function_t)(check_fs)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"rename",
"renames a file",
(cmd_function_t)(file_rename)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"get",
"gets a parameter",
(cmd_function_t)(get),
0
);
SHELL_RegisterCommand(&MySerialShell,
"mget",
"mini get. Returns only 1 parameter at a time without min&max",
(cmd_function_t)(mget),
0
);
SHELL_RegisterCommand(&MySerialShell,
"set",
"sets a parameter",
(cmd_function_t)(set),
0
);
SHELL_RegisterCommand(&MySerialShell,
"mset",
"mini set. returns parameter change in mini get format",
(cmd_function_t)(mset),
0
);
SHELL_RegisterCommand(&MySerialShell,
"save",
"saves the current configuration parameters",
(cmd_function_t)(save_config),
0
);
SHELL_RegisterCommand(&MySerialShell,
"msave",
"saves the current configuration parameters without returning get",
(cmd_function_t)(msave),
0
);
SHELL_RegisterCommand(&MySerialShell,
"load",
"forces a load of configuration parameters from configuration file",
(cmd_function_t)(load_config),
0
);
SHELL_RegisterCommand(&MySerialShell,
"txt",
"sends an SMS text",
(cmd_function_t)(cell_txt),
0
);
SHELL_RegisterCommand(&MySerialShell,
"cell",
"gets cell information",
(cmd_function_t)(cell),
0
);
SHELL_RegisterCommand(&MySerialShell,
"wolftest",
"test the wolfcrypt backend",
(cmd_function_t)(wolf_test),
0
);
SHELL_RegisterCommand(&MySerialShell,
"epoch",
"Gets current Epoch time",
(cmd_function_t)(epoch),
0
);
SHELL_RegisterCommand(&MySerialShell,
"fcreate",
"creates a file open file",
(cmd_function_t)(Remote_fcreate),
0
);
SHELL_RegisterCommand(&MySerialShell,
"fwrite",
"writes binary data to a file",
(cmd_function_t)(Remote_fwrite),
0
);
SHELL_RegisterCommand(&MySerialShell,
"fwriteb64",
"writes binary data to a file",
(cmd_function_t)(Remote_fwriteb64),
0
);
SHELL_RegisterCommand(&MySerialShell,
"fwriteline",
"write a line of text to a file",
(cmd_function_t)(Remote_fwriteline) ,
0
);
SHELL_RegisterCommand(&MySerialShell,
"md5sum",
"computes the md5 digest of a file",
(cmd_function_t)(md5check)
,0
);
SHELL_RegisterCommand(&MySerialShell,
"probe",
"gets the birth records of the probes",
(cmd_function_t)(probe),
0
);
SHELL_RegisterCommand(&MySerialShell,
"pp",
"cycles power on a channel",
(cmd_function_t)(pp),
0
);
SHELL_RegisterCommand(&MySerialShell,
"at",
"manual AT command to modem",
(cmd_function_t)(cell_at),
0
);
/*
SHELL_RegisterCommand(&MySerialShell,
"validate",
"validate a boot image",
(cmd_function_t)(validate_boot_file)
);
*/
//);
SHELL_printf(&MySerialShell,"\r\n");
SHELL_printf(&MySerialShell,MySerialShell.prompt);
ShellHasBeenInitialized = 1;
}
uint32_t ShellUART_TxActive = 0 ;
uint8_t UartInByte = 0;
#if ENABLE_SHELL_TO_SPI_SERIAL == 1
#define SPI_UART_TX_QUEUE_SIZE 4096
uint8_t SPI_UART_QueueStorage[SPI_UART_TX_QUEUE_SIZE];
ByteQueue SPI_UART_TX_Q;
#endif
void Init_Shell_IO()
{
ShellUART_TxActive = 0 ;
#if ENABLE_SHELL_TO_SPI_SERIAL == 1
InitByteQueue(&SPI_UART_TX_Q, SPI_UART_TX_QUEUE_SIZE, SPI_UART_QueueStorage);
SC16IS741A_Init();
#endif
#if ENABLE_SHELL_TO_UART == 1
/* Initialize UART hardware: */
NRF_UARTE1->PSELTXD = NRF_GPIO_PIN_MAP(SERIAL_IF_TXD_PORT_NUMBER,SERIAL_IF_TXD_PIN_NUMBER);
NRF_UARTE1->PSELRXD = NRF_GPIO_PIN_MAP(SERIAL_IF_RXD_PORT_NUMBER,SERIAL_IF_RXD_PIN_NUMBER);
NRF_UARTE1->CONFIG = (HWFC ? UARTE_CONFIG_HWFC_Enabled : UARTE_CONFIG_HWFC_Disabled) << UART_CONFIG_HWFC_Pos;
NRF_UARTE1->BAUDRATE = UARTE_BAUDRATE_BAUDRATE_Baud115200 << UARTE_BAUDRATE_BAUDRATE_Pos;
NRF_UARTE1->ENABLE = UARTE_ENABLE_ENABLE_Enabled << UARTE_ENABLE_ENABLE_Pos;
NRF_UARTE1->INTEN = UARTE_INTEN_ENDRX_Msk | UARTE_INTEN_ENDTX_Msk;
NRF_UARTE1->TASKS_FLUSHRX = 1;
NRF_UARTE1->RXD.MAXCNT = 1;
NRF_UARTE1->RXD.PTR = &UartInByte;
NRF_UARTE1->TASKS_STARTRX = 1;
NVIC_SetPriority(UARTE1_IRQn, NRF_MESH_IRQ_PRIORITY_LOWEST);
NVIC_EnableIRQ(UARTE1_IRQn);
#endif
}
#if ENABLE_SHELL_TO_UART == 1
uint8_t TxOutBuf[256];
uint32_t TxChunk()
{
uint32_t TxScheduled = 0;
uint32_t BytesInQ = BytesInQueue(&Shell_Uart_OutputQueue);
if(BytesInQ)
{
if(BytesInQ>255)
BytesInQ = 255;
for(int i=0;i<BytesInQ;i++)
{
ByteDequeue(&Shell_Uart_OutputQueue,&TxOutBuf[i]);
}
NRF_UARTE1->TXD.MAXCNT = BytesInQ;
NRF_UARTE1->TXD.PTR = &TxOutBuf[0];
NRF_UARTE1->TASKS_STARTTX = 1;
TxScheduled = 1;
}
return TxScheduled;
}
void UARTE1_IRQHandler(void)
{
if(NRF_UARTE1->EVENTS_ENDRX)
{
NRF_UARTE1->EVENTS_ENDRX = 0;
NRF_UARTE1->TASKS_STARTRX = 1;
if(NRF_UARTE1->RXD.AMOUNT == 1)
{
ByteEnqueue(&ShellInputQueue,UartInByte);
}
}
if(NRF_UARTE1->EVENTS_ENDTX)
{
NRF_UARTE1->EVENTS_ENDTX = 0;
NRF_UARTE1->TASKS_STOPTX = 1;
ShellUART_TxActive = TxChunk();
}
/* transmit any pending bytes */
//if (NRF_UART0->EVENTS_TXDRDY)
// {
// NRF_UART0->EVENTS_TXDRDY = 0;
// (void) NRF_UART0->EVENTS_TXDRDY;
// if(BytesInQueue(&Shell_Uart_OutputQueue) == 0)
// {
// NRF_UART0->TASKS_STOPTX = 1;
// ShellUART_TxActive = 0;
// }
// else
// {
// uint8_t DataOut;
// ByteDequeue(&Shell_Uart_OutputQueue,&DataOut);
// NRF_UART0->TXD = DataOut;
// }
// }
}
#endif
void Shell_MoveQueues()
{
if(ShellHasBeenInitialized == 0)
return;
uint32_t NumBytesInOutputQueue = BytesInQueue(&ShellOutputQueue);
uint8_t DataOut = 0;
if(NumBytesInOutputQueue > 0)
{
for(int i=0;i<NumBytesInOutputQueue;i++)
{
ByteDequeue(&ShellOutputQueue,&DataOut);
#if ENABLE_SHELL_TO_UART == 1
ByteEnqueue(&Shell_Uart_OutputQueue,DataOut);
#endif
#if ENABLE_SHELL_TO_RTT == 1
ShellTempOutputBuffer[i] = DataOut;
#endif
ByteEnqueue(&SPI_UART_TX_Q,DataOut);
if(FourChannel__IsEscaped())
{
ByteEnqueue(&RS485_OutputQueue,DataOut);
}
}
#if ENABLE_SHELL_TO_RTT == 1
SEGGER_RTT_Write(0,&ShellTempOutputBuffer[0],NumBytesInOutputQueue);
#endif
}
#if ENABLE_SHELL_TO_RTT == 1
while(SEGGER_RTT_HasKey())
{
ByteEnqueue(&ShellInputQueue, SEGGER_RTT_GetKey());
}
#endif
#if ENABLE_SHELL_TO_UART == 1
if (ShellUART_TxActive == 0)
{
ShellUART_TxActive = TxChunk();
}
#endif
#if ENABLE_SHELL_TO_SPI_SERIAL == 1
uint32_t BytesToTx;
uint32_t MaxtoTx;
BytesToTx = BytesInQueue(&SPI_UART_TX_Q);
if(BytesToTx)
{
MaxtoTx = SC16IS741A_ReadRegister(SC16IS741A__TXLVL);
if(BytesToTx>MaxtoTx)
BytesToTx = MaxtoTx;
if(BytesToTx>64)
BytesToTx = 64;
uint8_t Buf[BytesToTx];
ByteArrayDequeue(&SPI_UART_TX_Q,Buf,BytesToTx);
SC16IS741A_WriteTxFIFO(Buf,BytesToTx);
}
uint32_t BytesToRx = SC16IS741A_ReadRegister(SC16IS741A__RXLVL);
if(BytesToRx)
{
if(BytesToRx>64)
BytesToRx = 64;
uint8_t Buf[BytesToRx];
SC16IS741A_ReadRxFIFO(Buf,BytesToRx);
for(int i=0;i<BytesToRx;i++)
{
ByteEnqueue(&ShellInputQueue,Buf[i]);
}
}
#endif
}
| [
"eli.hughes@tzerolabs.com"
] | eli.hughes@tzerolabs.com |
6ba683bd8cfc113b5be37c0ed6176a94a6a48a27 | aa028959c22f60f2e60b0c2317ad2fc2a2f64288 | /code/helpers.h | 473a118517a411d7b3476c26549666f9459d1a42 | [] | no_license | 4lhc/TWIP-Self-Balancing-Robot | 09c85477675098e2cced41e518919dd6cb9a13a0 | 713269c56cb658a7c5950669e105cd43f22a5994 | refs/heads/master | 2022-09-09T03:16:19.947569 | 2020-05-26T15:06:01 | 2020-05-26T15:06:01 | 266,800,265 | 1 | 0 | null | null | null | null | UTF-8 | C | false | false | 583 | h | /***********************************************************************
File Name : helpers.h
Project : Self Balancing Robot
Author : Sreejith S, Karthik
Date : 08 Dec 2019
Platform : Tiva Development Kit EK-TM4C123GXL
Descirption : Misc helper functions
***********************************************************************/
#ifndef HELPER_H
#define HELPER_H
#include <inttypes.h>
#include <stdlib.h>
intmax_t str_to_int(char* string);
float str_to_float(char* string);
#endif
| [
"444lhc@gmail.com"
] | 444lhc@gmail.com |
dbe25e1d313852071cf498103595d357c01bc124 | 8028c77435920a39892a421fca1e444a5fd9eacc | /apps/gps/fsw/unit_test/gps_custom_stubs.c | d55fdf62ed52161293c17d484b5928fcf68725c5 | [
"BSD-3-Clause"
] | permissive | WindhoverLabs/airliner | fc2b2d59c73efc8f63c6fb8b3c4e00c5fddcc7c7 | 2ab9c8717e0a42d40b0d014a22dbcc1ed7ec0eb1 | refs/heads/integration | 2023-08-04T06:01:53.480641 | 2023-07-31T03:22:06 | 2023-07-31T03:22:06 | 332,887,132 | 9 | 2 | null | 2023-07-31T02:58:48 | 2021-01-25T21:21:52 | C | UTF-8 | C | false | false | 2,208 | c | /****************************************************************************
*
* Copyright (c) 2017 Windhover Labs, L.L.C. 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.
* 3. Neither the name Windhover Labs nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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.
*
*****************************************************************************/
#include "gps_custom_stubs.h"
#include "px4_msgs.h"
void GPS_Custom_InitData(void)
{
}
boolean GPS_Custom_Init(void)
{
return TRUE;
}
boolean GPS_Custom_Uninit(void)
{
return TRUE;
}
int32 GPS_Custom_Init_EventFilters(int32 ind, CFE_EVS_BinFilter_t *EventTbl)
{
return 0;
}
boolean GPS_Custom_Measure_PositionMsg(PX4_VehicleGpsPositionMsg_t *Measure)
{
return TRUE;
}
boolean GPS_Custom_Measure_SatInfoMsg(PX4_SatelliteInfoMsg_t *Measure)
{
return TRUE;
}
| [
"mbenson@windhoverlabs.com"
] | mbenson@windhoverlabs.com |
cdacb687653c195e817278daeb7a0a2a2c6b7f0f | cfe69fc556729bdecf2118fa5bc329343c42ed80 | /10.0.10240.16384/ntoskrnl/Functions/SepSecureBootFilterBootOptionDelete.c | aa8f0409875cd49aeedfc336f535ec6bc4e5cbe5 | [] | no_license | Myprivateclonelibrary/W10M_unedited-decomp | 8e5ec89a20e634ffc53457a40b0fd6d8a9e1757a | 67b05851a3e262ff8a5d11ee50db34f28c350f16 | refs/heads/main | 2023-08-31T06:00:37.303105 | 2021-05-15T23:53:23 | 2021-05-15T23:53:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 276 | c | // SepSecureBootFilterBootOptionDelete
int __fastcall SepSecureBootFilterBootOptionDelete(int a1)
{
int v1; // r1
_WORD *v2; // r2
v1 = 0;
v2 = (_WORD *)(*(_DWORD *)(a1 + 8) + dword_64185C);
if ( (*v2 & 0x1F) != 8 || v2[1] )
v1 = -1069350910;
return v1;
}
| [
"64583248+Empyreal96@users.noreply.github.com"
] | 64583248+Empyreal96@users.noreply.github.com |
035a45a42882ae68fc31c95fcf29ef2e1450f065 | 5c255f911786e984286b1f7a4e6091a68419d049 | /code/bbb9dec5-1b42-4eff-b910-3d7f0e4e34f9.c | 56df23c684aaa47a25bc75d2f7e8f645dfcffb32 | [] | no_license | nmharmon8/Deep-Buffer-Overflow-Detection | 70fe02c8dc75d12e91f5bc4468cf260e490af1a4 | e0c86210c86afb07c8d4abcc957c7f1b252b4eb2 | refs/heads/master | 2021-09-11T19:09:59.944740 | 2018-04-06T16:26:34 | 2018-04-06T16:26:34 | 125,521,331 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 237 | c | #include <stdio.h>
int main() {
int i=4;
int j=13;
int k;
int l;
j = 53;
l = 64;
k = i/j;
l = j/j;
l = i/j;
l = k%j;
l = k%j;
k = k-k*i;
printf("vulnerability");
printf("%d\n",k);
return 0;
}
| [
"nharmon8@gmail.com"
] | nharmon8@gmail.com |
ea801c6d280382a3229e67fd88046b354a7b45c5 | bb604482a2885b688107910bd9bb031df533e9ff | /helloworld.c | 48032700ba4b6b23507a918032d2b768f175bfed | [] | no_license | magiman7/ELEN-423 | c9c17dd6b4d303d9f2c3f8cf272fc7dfabad2cd0 | cd8f2fab6aa03fb576b5f85bae0ca7b5a9c2f06e | refs/heads/master | 2021-01-17T08:36:12.257177 | 2014-10-21T04:27:34 | 2014-10-21T04:27:34 | 25,532,435 | 1 | 0 | null | null | null | null | UTF-8 | C | false | false | 2,891 | c | /*
* Copyright (c) 2009 Xilinx, Inc. All rights reserved.
*
* Xilinx, Inc.
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
* COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
* ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
* STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
* IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
* FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
* XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
* THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
* ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
* FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE.
*
*/
// Edited 10/16/13 2:48 PM
/*
* helloworld.c: simple test application
*/
#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "mb_interface.h"
#define INT_ISR *(volatile int*)(XPAR_XPS_INTC_0_BASEADDR) //Interupt status
#define INT_IPR *(volatile int*)(XPAR_XPS_INTC_0_BASEADDR+4) //Interrupt Pending
#define INT_IER *(volatile int*)(XPAR_XPS_INTC_0_BASEADDR+8) //Interrupt Enable
#define INT_IAR *(volatile int*)(XPAR_XPS_INTC_0_BASEADDR+0x0C) //Interrupt Acknowledge
#define INT_MER *(volatile int*)(XPAR_XPS_INTC_0_BASEADDR+0x1c) //Master Enable
#define port2_data *(volatile int*)(XPAR_XPS_GPIO_2_BASEADDR)
#define port2_direction *(volatile int*)(XPAR_XPS_GPIO_2_BASEADDR+4)
#define port2_GIER *(volatile int*)(XPAR_XPS_GPIO_2_BASEADDR+0x11c)
#define port2_IPISR *(volatile int*)(XPAR_XPS_GPIO_2_BASEADDR+0x120)
#define port2_IPIER *(volatile int*)(XPAR_XPS_GPIO_2_BASEADDR+0x128)
void interrupt(void) __attribute__ ((interrupt_handler));
void print(char *str);
char que[17];
char head = 0;
int main()
{
init_platform();
INT_IER=0x01; //next three lines enable interrupts (I don't think order matters)
INT_MER=0x03;
microblaze_enable_interrupts();
port2_direction = 7;
port2_IPIER = 1;
port2_GIER=0x80000000;
int i;
int ii;
char tail = 0;
//---------------------------------------------------------- Event Que
while(1){
if(tail!= head){
xil_printf("%d\r\n", que[tail]);
tail++;
port2_IPIER = 0;
for (i=0;i<50;i++){
for (ii=0;ii<65000;ii++){
}
}
port2_IPIER=0x1;
} #comment added Dr. Hummel
}
//this is what I am adding here
cleanup_platform();
return 0;
}
void interrupt(void){
int temp1;
//read the IPR register
temp1=INT_IPR;
//make necessary changes
que[head]=port2_data; //write to que
head++; //increment head
port2_IPISR=port2_IPISR; //the interrupt bits are set up such that if you write a 1 to it is the only way to manually to change it
//clear the interrupts that have been handled
INT_IAR=temp1;
}
| [
"phummel@latech.edu"
] | phummel@latech.edu |
0bbb7bb1d54fc6fd8fea1b266e1a954a2ddae45f | 4d5f2cdc0b7120f74ba6f357b21dac063e71b606 | /postgresql/src/bin/psql/print.c | a263f1f27677879e843f76112b8df0b503af1b0a | [
"BSD-2-Clause",
"PostgreSQL"
] | permissive | anjingbin/starccm | cf499238ceb1e4f0235421cb6f3cb823b932a2cd | 70db48004aa20bbb82cc24de80802b40c7024eff | refs/heads/master | 2021-01-11T19:49:04.306906 | 2017-01-19T02:02:50 | 2017-01-19T02:02:50 | 79,404,002 | 2 | 0 | null | null | null | null | UTF-8 | C | false | false | 24,834 | c | /*
* psql - the PostgreSQL interactive terminal
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /home/hjcvs/OB-CCM-1.0/postgresql/src/bin/psql/print.c,v 1.2 2004/07/05 08:55:54 SuLiang Exp $
*/
#include "postgres_fe.h"
#include "print.h"
#include <math.h>
#include <signal.h>
#ifndef WIN32
#include <unistd.h> /* for isatty() */
#include <sys/ioctl.h> /* for ioctl() */
#else
#define popen(x,y) _popen(x,y)
#define pclose(x) _pclose(x)
#endif
#include "pqsignal.h"
#include "libpq-fe.h"
#include "settings.h"
#ifndef __CYGWIN__
#define DEFAULT_PAGER "more"
#else
#define DEFAULT_PAGER "less"
#endif
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#include "mbprint.h"
/*************************/
/* Unaligned text */
/*************************/
static void
print_unaligned_text(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
const char *opt_fieldsep, const char *opt_recordsep, bool opt_barebones,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
const char *const * ptr;
bool need_recordsep = false;
if (!opt_fieldsep)
opt_fieldsep = "";
if (!opt_recordsep)
opt_recordsep = "";
/* print title */
if (!opt_barebones && title)
fprintf(fout, "%s%s", title, opt_recordsep);
/* print headers and count columns */
for (ptr = headers; *ptr; ptr++)
{
col_count++;
if (!opt_barebones)
{
if (col_count > 1)
fputs(opt_fieldsep, fout);
fputs(*ptr, fout);
}
}
if (!opt_barebones)
need_recordsep = true;
/* print cells */
i = 0;
for (ptr = cells; *ptr; ptr++)
{
if (need_recordsep)
{
fputs(opt_recordsep, fout);
need_recordsep = false;
}
fputs(*ptr, fout);
if ((i + 1) % col_count)
fputs(opt_fieldsep, fout);
else
need_recordsep = true;
i++;
}
/* print footers */
if (!opt_barebones && footers)
for (ptr = footers; *ptr; ptr++)
{
if (need_recordsep)
{
fputs(opt_recordsep, fout);
need_recordsep = false;
}
fputs(*ptr, fout);
need_recordsep = true;
}
/* the last record needs to be concluded with a newline */
if (need_recordsep)
fputc('\n', fout);
}
static void
print_unaligned_vertical(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
const char *opt_fieldsep, const char *opt_recordsep, bool opt_barebones,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
const char *const * ptr;
if (!opt_fieldsep)
opt_fieldsep = "";
if (!opt_recordsep)
opt_recordsep = "";
/* print title */
if (!opt_barebones && title)
fputs(title, fout);
/* count columns */
for (ptr = headers; *ptr; ptr++)
col_count++;
/* print records */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
if (i != 0 || (!opt_barebones && title))
{
fputs(opt_recordsep, fout);
if (i % col_count == 0)
fputs(opt_recordsep, fout); /* another one */
}
fputs(headers[i % col_count], fout);
fputs(opt_fieldsep, fout);
fputs(*ptr, fout);
}
/* print footers */
if (!opt_barebones && footers && *footers)
{
fputs(opt_recordsep, fout);
for (ptr = footers; *ptr; ptr++)
{
fputs(opt_recordsep, fout);
fputs(*ptr, fout);
}
}
fputc('\n', fout);
}
/********************/
/* Aligned text */
/********************/
/* draw "line" */
static void
_print_horizontal_line(const unsigned int col_count, const unsigned int *widths, unsigned short border, FILE *fout)
{
unsigned int i,
j;
if (border == 1)
fputc('-', fout);
else if (border == 2)
fputs("+-", fout);
for (i = 0; i < col_count; i++)
{
for (j = 0; j < widths[i]; j++)
fputc('-', fout);
if (i < col_count - 1)
{
if (border == 0)
fputc(' ', fout);
else
fputs("-+-", fout);
}
}
if (border == 2)
fputs("-+", fout);
else if (border == 1)
fputc('-', fout);
fputc('\n', fout);
}
static void
print_aligned_text(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_barebones,
unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
#ifdef MULTIBYTE
unsigned int cell_count = 0;
unsigned int *head_w,
*cell_w;
#endif
unsigned int i,
tmp;
unsigned int *widths,
total_w;
const char *const * ptr;
/* count columns */
for (ptr = headers; *ptr; ptr++)
col_count++;
widths = calloc(col_count, sizeof(*widths));
if (!widths)
{
perror("calloc");
exit(EXIT_FAILURE);
}
#ifdef MULTIBYTE
head_w = calloc(col_count, sizeof(*head_w));
if (!head_w)
{
perror("calloc");
exit(EXIT_FAILURE);
}
/* count rows */
for (ptr = cells; *ptr; ptr++)
cell_count++;
if (cell_count > 0)
{
cell_w = calloc(cell_count, sizeof(*cell_w));
if (!cell_w)
{
perror("calloc");
exit(EXIT_FAILURE);
}
}
else
cell_w = 0;
#endif
/* calc column widths */
for (i = 0; i < col_count; i++)
{
if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > widths[i])
widths[i] = tmp;
#ifdef MULTIBYTE
head_w[i] = tmp;
#endif
}
for (i = 0, ptr = cells; *ptr; ptr++, i++)
{
if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > widths[i % col_count])
widths[i % col_count] = tmp;
#ifdef MULTIBYTE
cell_w[i] = tmp;
#endif
}
if (opt_border == 0)
total_w = col_count - 1;
else if (opt_border == 1)
total_w = col_count * 3 - 1;
else
total_w = col_count * 3 + 1;
for (i = 0; i < col_count; i++)
total_w += widths[i];
/* print title */
if (title && !opt_barebones)
{
int tlen;
if ((tlen = pg_wcswidth((unsigned char *) title, strlen(title))) >= total_w)
fprintf(fout, "%s\n", title);
else
fprintf(fout, "%-*s%s\n", (int) (total_w - tlen) / 2, "", title);
}
/* print headers */
if (!opt_barebones)
{
if (opt_border == 2)
_print_horizontal_line(col_count, widths, opt_border, fout);
if (opt_border == 2)
fputs("| ", fout);
else if (opt_border == 1)
fputc(' ', fout);
for (i = 0; i < col_count; i++)
{
int nbspace;
#ifdef MULTIBYTE
nbspace = widths[i] - head_w[i];
#else
nbspace = widths[i] - strlen(headers[i]);
#endif
/* centered */
fprintf(fout, "%-*s%s%-*s",
nbspace / 2, "", headers[i], (nbspace + 1) / 2, "");
if (i < col_count - 1)
{
if (opt_border == 0)
fputc(' ', fout);
else
fputs(" | ", fout);
}
}
if (opt_border == 2)
fputs(" |", fout);
else if (opt_border == 1)
fputc(' ', fout);;
fputc('\n', fout);
_print_horizontal_line(col_count, widths, opt_border, fout);
}
/* print cells */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
/* beginning of line */
if (i % col_count == 0)
{
if (opt_border == 2)
fputs("| ", fout);
else if (opt_border == 1)
fputc(' ', fout);
}
/* content */
if (opt_align[(i) % col_count] == 'r')
{
#ifdef MULTIBYTE
fprintf(fout, "%*s%s",
widths[i % col_count] - cell_w[i], "", cells[i]);
#else
fprintf(fout, "%*s", widths[i % col_count], cells[i]);
#endif
}
else
{
if ((i + 1) % col_count == 0 && opt_border != 2)
fputs(cells[i], fout);
else
{
#ifdef MULTIBYTE
fprintf(fout, "%-s%*s", cells[i],
widths[i % col_count] - cell_w[i], "");
#else
fprintf(fout, "%-*s", widths[i % col_count], cells[i]);
#endif
}
}
/* divider */
if ((i + 1) % col_count)
{
if (opt_border == 0)
fputc(' ', fout);
else
fputs(" | ", fout);
}
/* end of line */
else
{
if (opt_border == 2)
fputs(" |", fout);
fputc('\n', fout);
}
}
if (opt_border == 2)
_print_horizontal_line(col_count, widths, opt_border, fout);
/* print footers */
if (footers && !opt_barebones)
for (ptr = footers; *ptr; ptr++)
fprintf(fout, "%s\n", *ptr);
fputc('\n', fout);
/* clean up */
#ifdef MULTIBYTE
free(cell_w);
free(head_w);
#endif
free(widths);
}
static void
print_aligned_vertical(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
bool opt_barebones, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int record = 1;
const char *const * ptr;
unsigned int i,
tmp = 0,
hwidth = 0,
dwidth = 0;
char *divider;
#ifdef MULTIBYTE
unsigned int cell_count = 0;
unsigned int *cell_w,
*head_w;
#endif
if (cells[0] == NULL)
{
puts(gettext("(No rows)\n"));
return;
}
#ifdef MULTIBYTE
/* pre-count headers */
for (ptr = headers; *ptr; ptr++)
col_count++;
head_w = calloc(col_count, sizeof(*head_w));
if (!head_w)
{
perror("calloc");
exit(EXIT_FAILURE);
}
for (i = 0; i < col_count; i++)
{
if ((tmp = pg_wcswidth((unsigned char *) headers[i], strlen(headers[i]))) > hwidth)
hwidth = tmp;
head_w[i] = tmp;
}
for (ptr = cells; *ptr; ptr++)
cell_count++;
if (cell_count > 0)
{
cell_w = calloc(cell_count, sizeof(*cell_w));
if (!cell_w)
{
perror("calloc");
exit(EXIT_FAILURE);
}
}
else
cell_w = 0;
/* find longest data cell */
for (i = 0, ptr = cells; *ptr; ptr++, i++)
{
if ((tmp = pg_wcswidth((unsigned char *) *ptr, strlen(*ptr))) > dwidth)
dwidth = tmp;
cell_w[i] = tmp;
}
#else
/* count columns and find longest header */
for (ptr = headers; *ptr; ptr++)
{
col_count++;
if ((tmp = strlen(*ptr)) > hwidth)
hwidth = tmp; /* don't wanna call strlen twice */
}
/* find longest data cell */
for (ptr = cells; *ptr; ptr++)
{
if ((tmp = strlen(*ptr)) > dwidth)
dwidth = tmp;
}
#endif
/* print title */
if (!opt_barebones && title)
fprintf(fout, "%s\n", title);
/* make horizontal border */
divider = malloc(hwidth + dwidth + 10);
if (!divider)
{
perror("malloc");
exit(EXIT_FAILURE);
}
divider[0] = '\0';
if (opt_border == 2)
strcat(divider, "+-");
for (i = 0; i < hwidth; i++)
strcat(divider, opt_border > 0 ? "-" : " ");
if (opt_border > 0)
strcat(divider, "-+-");
else
strcat(divider, " ");
for (i = 0; i < dwidth; i++)
strcat(divider, opt_border > 0 ? "-" : " ");
if (opt_border == 2)
strcat(divider, "-+");
/* print records */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
if (i % col_count == 0)
{
if (!opt_barebones)
{
char *record_str = malloc(32);
size_t record_str_len;
if (!record_str)
{
perror("malloc");
exit(EXIT_FAILURE);
}
if (opt_border == 0)
sprintf(record_str, "* Record %d", record++);
else
sprintf(record_str, "[ RECORD %d ]", record++);
record_str_len = strlen(record_str);
if (record_str_len + opt_border > strlen(divider))
fprintf(fout, "%.*s%s\n", opt_border, divider, record_str);
else
{
char *div_copy = strdup(divider);
if (!div_copy)
{
perror("malloc");
exit(EXIT_FAILURE);
}
strncpy(div_copy + opt_border, record_str, record_str_len);
fprintf(fout, "%s\n", div_copy);
free(div_copy);
}
free(record_str);
}
else if (i != 0 || opt_border == 2)
fprintf(fout, "%s\n", divider);
}
if (opt_border == 2)
fputs("| ", fout);
#if MULTIBYTE
fprintf(fout, "%-s%*s", headers[i % col_count],
hwidth - head_w[i % col_count], "");
#else
fprintf(fout, "%-*s", hwidth, headers[i % col_count]);
#endif
if (opt_border > 0)
fputs(" | ", fout);
else
fputs(" ", fout);
if (opt_border < 2)
fprintf(fout, "%s\n", *ptr);
else
{
#ifdef MULTIBYTE
fprintf(fout, "%-s%*s |\n", *ptr, dwidth - cell_w[i], "");
#else
fprintf(fout, "%-*s |\n", dwidth, *ptr);
#endif
}
}
if (opt_border == 2)
fprintf(fout, "%s\n", divider);
/* print footers */
if (!opt_barebones && footers && *footers)
{
if (opt_border < 2)
fputc('\n', fout);
for (ptr = footers; *ptr; ptr++)
fprintf(fout, "%s\n", *ptr);
}
fputc('\n', fout);
free(divider);
#ifdef MULTIBYTE
free(cell_w);
#endif
}
/**********************/
/* HTML printing ******/
/**********************/
static void
html_escaped_print(const char *in, FILE *fout)
{
const char *p;
for (p = in; *p; p++)
switch (*p)
{
case '&':
fputs("&", fout);
break;
case '<':
fputs("<", fout);
break;
case '>':
fputs(">", fout);
break;
case '\n':
fputs("<br>", fout);
break;
default:
fputc(*p, fout);
}
}
static void
print_html_text(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
const char *opt_table_attr,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
const char *const * ptr;
fprintf(fout, "<table border=%d", opt_border);
if (opt_table_attr)
fprintf(fout, " %s", opt_table_attr);
fputs(">\n", fout);
/* print title */
if (!opt_barebones && title)
{
fputs(" <caption>", fout);
html_escaped_print(title, fout);
fputs("</caption>\n", fout);
}
/* print headers and count columns */
if (!opt_barebones)
fputs(" <tr>\n", fout);
for (i = 0, ptr = headers; *ptr; i++, ptr++)
{
col_count++;
if (!opt_barebones)
{
fputs(" <th align=center>", fout);
html_escaped_print(*ptr, fout);
fputs("</th>\n", fout);
}
}
if (!opt_barebones)
fputs(" </tr>\n", fout);
/* print cells */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
if (i % col_count == 0)
fputs(" <tr valign=top>\n", fout);
fprintf(fout, " <td align=%s>", opt_align[(i) % col_count] == 'r' ? "right" : "left");
if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only
* whitespace? */
fputs(" ", fout);
else
html_escaped_print(*ptr, fout);
fputs("</td>\n", fout);
if ((i + 1) % col_count == 0)
fputs(" </tr>\n", fout);
}
fputs("</table>\n", fout);
/* print footers */
if (footers && !opt_barebones)
for (ptr = footers; *ptr; ptr++)
{
html_escaped_print(*ptr, fout);
fputs("<br>\n", fout);
}
fputc('\n', fout);
}
static void
print_html_vertical(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
const char *opt_table_attr,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
unsigned int record = 1;
const char *const * ptr;
fprintf(fout, "<table border=%d", opt_border);
if (opt_table_attr)
fprintf(fout, " %s", opt_table_attr);
fputs(">\n", fout);
/* print title */
if (!opt_barebones && title)
{
fputs(" <caption>", fout);
html_escaped_print(title, fout);
fputs("</caption>\n", fout);
}
/* count columns */
for (ptr = headers; *ptr; ptr++)
col_count++;
/* print records */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
if (i % col_count == 0)
{
if (!opt_barebones)
fprintf(fout, "\n <tr><td colspan=2 align=center>Record %d</td></tr>\n", record++);
else
fputs("\n <tr><td colspan=2> </td></tr>\n", fout);
}
fputs(" <tr valign=top>\n"
" <th>", fout);
html_escaped_print(headers[i % col_count], fout);
fputs("</th>\n", fout);
fprintf(fout, " <td align=%s>", opt_align[i % col_count] == 'r' ? "right" : "left");
if ((*ptr)[strspn(*ptr, " \t")] == '\0') /* is string only
* whitespace? */
fputs(" ", fout);
else
html_escaped_print(*ptr, fout);
fputs("</td>\n </tr>\n", fout);
}
fputs("</table>\n", fout);
/* print footers */
if (footers && !opt_barebones)
for (ptr = footers; *ptr; ptr++)
{
html_escaped_print(*ptr, fout);
fputs("<br>\n", fout);
}
fputc('\n', fout);
}
/*************************/
/* LaTeX */
/*************************/
static void
latex_escaped_print(const char *in, FILE *fout)
{
const char *p;
for (p = in; *p; p++)
switch (*p)
{
case '&':
fputs("\\&", fout);
break;
case '%':
fputs("\\%", fout);
break;
case '$':
fputs("\\$", fout);
break;
case '{':
fputs("\\{", fout);
break;
case '}':
fputs("\\}", fout);
break;
case '\\':
fputs("\\backslash", fout);
break;
case '\n':
fputs("\\\\", fout);
break;
default:
fputc(*p, fout);
}
}
static void
print_latex_text(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
const char *cp;
const char *const * ptr;
/* print title */
if (!opt_barebones && title)
{
fputs("\\begin{center}\n", fout);
latex_escaped_print(title, fout);
fputs("\n\\end{center}\n\n", fout);
}
/* begin environment and set alignments and borders */
fputs("\\begin{tabular}{", fout);
if (opt_border == 0)
fputs(opt_align, fout);
else if (opt_border == 1)
{
for (cp = opt_align; *cp; cp++)
{
if (cp != opt_align)
fputc('|', fout);
fputc(*cp, fout);
}
}
else if (opt_border == 2)
{
for (cp = opt_align; *cp; cp++)
{
fputc('|', fout);
fputc(*cp, fout);
}
fputc('|', fout);
}
fputs("}\n", fout);
if (!opt_barebones && opt_border == 2)
fputs("\\hline\n", fout);
/* print headers and count columns */
for (i = 0, ptr = headers; *ptr; i++, ptr++)
{
col_count++;
if (!opt_barebones)
{
if (i != 0)
fputs(" & ", fout);
latex_escaped_print(*ptr, fout);
}
}
if (!opt_barebones)
{
fputs(" \\\\\n", fout);
fputs("\\hline\n", fout);
}
/* print cells */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
latex_escaped_print(*ptr, fout);
if ((i + 1) % col_count == 0)
fputs(" \\\\\n", fout);
else
fputs(" & ", fout);
}
if (opt_border == 2)
fputs("\\hline\n", fout);
fputs("\\end{tabular}\n\n", fout);
/* print footers */
if (footers && !opt_barebones)
for (ptr = footers; *ptr; ptr++)
{
latex_escaped_print(*ptr, fout);
fputs(" \\\\\n", fout);
}
fputc('\n', fout);
}
static void
print_latex_vertical(const char *title, const char *const * headers,
const char *const * cells, const char *const * footers,
const char *opt_align, bool opt_barebones, unsigned short int opt_border,
FILE *fout)
{
unsigned int col_count = 0;
unsigned int i;
const char *const * ptr;
unsigned int record = 1;
(void) opt_align; /* currently unused parameter */
/* print title */
if (!opt_barebones && title)
{
fputs("\\begin{center}\n", fout);
latex_escaped_print(title, fout);
fputs("\n\\end{center}\n\n", fout);
}
/* begin environment and set alignments and borders */
fputs("\\begin{tabular}{", fout);
if (opt_border == 0)
fputs("cl", fout);
else if (opt_border == 1)
fputs("c|l", fout);
else if (opt_border == 2)
fputs("|c|l|", fout);
fputs("}\n", fout);
/* count columns */
for (ptr = headers; *ptr; ptr++)
col_count++;
/* print records */
for (i = 0, ptr = cells; *ptr; i++, ptr++)
{
/* new record */
if (i % col_count == 0)
{
if (!opt_barebones)
{
if (opt_border == 2)
fputs("\\hline\n", fout);
fprintf(fout, "\\multicolumn{2}{c}{Record %d} \\\\\n", record++);
}
if (opt_border >= 1)
fputs("\\hline\n", fout);
}
latex_escaped_print(headers[i % col_count], fout);
fputs(" & ", fout);
latex_escaped_print(*ptr, fout);
fputs(" \\\\\n", fout);
}
if (opt_border == 2)
fputs("\\hline\n", fout);
fputs("\\end{tabular}\n\n", fout);
/* print footers */
if (footers && !opt_barebones)
for (ptr = footers; *ptr; ptr++)
{
latex_escaped_print(*ptr, fout);
fputs(" \\\\\n", fout);
}
fputc('\n', fout);
}
/********************************/
/* Public functions */
/********************************/
void
printTable(const char *title,
const char *const * headers,
const char *const * cells,
const char *const * footers,
const char *align,
const printTableOpt *opt, FILE *fout)
{
const char *default_footer[] = {NULL};
unsigned short int border = opt->border;
FILE *pager = NULL,
*output;
if (opt->format == PRINT_NOTHING)
return;
if (!footers)
footers = default_footer;
if (opt->format != PRINT_HTML && border > 2)
border = 2;
/* check whether we need / can / are supposed to use pager */
if (fout == stdout && opt->pager
#ifndef WIN32
&&
isatty(fileno(stdin)) &&
isatty(fileno(stdout))
#endif
)
{
const char *pagerprog;
#ifdef TIOCGWINSZ
unsigned int col_count = 0,
row_count = 0,
lines;
const char *const * ptr;
int result;
struct winsize screen_size;
/* rough estimate of columns and rows */
if (headers)
for (ptr = headers; *ptr; ptr++)
col_count++;
if (cells)
for (ptr = cells; *ptr; ptr++)
row_count++;
row_count /= col_count;
if (opt->expanded)
lines = (col_count + 1) * row_count;
else
lines = row_count + 1;
if (!opt->tuples_only)
lines += 5;
result = ioctl(fileno(stdout), TIOCGWINSZ, &screen_size);
if (result == -1 || lines > screen_size.ws_row)
{
#endif
pagerprog = getenv("PAGER");
if (!pagerprog)
pagerprog = DEFAULT_PAGER;
pager = popen(pagerprog, "w");
#ifdef TIOCGWINSZ
}
#endif
}
if (pager)
{
output = pager;
#ifndef WIN32
pqsignal(SIGPIPE, SIG_IGN);
#endif
}
else
output = fout;
/* print the stuff */
switch (opt->format)
{
case PRINT_UNALIGNED:
if (opt->expanded)
print_unaligned_vertical(title, headers, cells, footers, opt->fieldSep, opt->recordSep, opt->tuples_only, output);
else
print_unaligned_text(title, headers, cells, footers, opt->fieldSep, opt->recordSep, opt->tuples_only, output);
break;
case PRINT_ALIGNED:
if (opt->expanded)
print_aligned_vertical(title, headers, cells, footers, opt->tuples_only, border, output);
else
print_aligned_text(title, headers, cells, footers, align, opt->tuples_only, border, output);
break;
case PRINT_HTML:
if (opt->expanded)
print_html_vertical(title, headers, cells, footers, align, opt->tuples_only, border, opt->tableAttr, output);
else
print_html_text(title, headers, cells, footers, align, opt->tuples_only, border, opt->tableAttr, output);
break;
case PRINT_LATEX:
if (opt->expanded)
print_latex_vertical(title, headers, cells, footers, align, opt->tuples_only, border, output);
else
print_latex_text(title, headers, cells, footers, align, opt->tuples_only, border, output);
break;
default:
fprintf(stderr, "+ Oops, you shouldn't see this!\n");
}
if (pager)
{
pclose(pager);
#ifndef WIN32
pqsignal(SIGPIPE, SIG_DFL);
#endif
}
}
void
printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
{
int nfields;
const char **headers;
const char **cells;
char **footers;
char *align;
int i;
/* extract headers */
nfields = PQnfields(result);
headers = calloc(nfields + 1, sizeof(*headers));
if (!headers)
{
perror("calloc");
exit(EXIT_FAILURE);
}
for (i = 0; i < nfields; i++)
{
#ifdef MULTIBYTE
headers[i] = mbvalidate(PQfname(result, i));
#else
headers[i] = PQfname(result, i);
#endif
}
/* set cells */
cells = calloc(nfields * PQntuples(result) + 1, sizeof(*cells));
if (!cells)
{
perror("calloc");
exit(EXIT_FAILURE);
}
for (i = 0; i < nfields * PQntuples(result); i++)
{
if (PQgetisnull(result, i / nfields, i % nfields))
cells[i] = opt->nullPrint ? opt->nullPrint : "";
else
{
#ifdef MULTIBYTE
cells[i] = mbvalidate(PQgetvalue(result, i / nfields, i % nfields));
#else
cells[i] = PQgetvalue(result, i / nfields, i % nfields);
#endif
}
}
/* set footers */
if (opt->footers)
footers = opt->footers;
else if (!opt->topt.expanded && opt->default_footer)
{
footers = calloc(2, sizeof(*footers));
if (!footers)
{
perror("calloc");
exit(EXIT_FAILURE);
}
footers[0] = malloc(100);
if (PQntuples(result) == 1)
snprintf(footers[0], 100, gettext("(1 row)"));
else
snprintf(footers[0], 100, gettext("(%d rows)"), PQntuples(result));
}
else
footers = NULL;
/* set alignment */
align = calloc(nfields + 1, sizeof(*align));
if (!align)
{
perror("calloc");
exit(EXIT_FAILURE);
}
for (i = 0; i < nfields; i++)
{
Oid ftype = PQftype(result, i);
if (ftype == 20 || /* int8 */
ftype == 21 || /* int2 */
ftype == 23 || /* int4 */
(ftype >= 26 && ftype <= 30) || /* ?id */
ftype == 700 || /* float4 */
ftype == 701 || /* float8 */
ftype == 790 || /* money */
ftype == 1700 /* numeric */
)
align[i] = 'r';
else
align[i] = 'l';
}
/* call table printer */
printTable(opt->title, headers, cells,
footers ? (const char *const *) footers : (const char *const *) (opt->footers),
align, &opt->topt, fout);
free(headers);
free(cells);
if (footers)
{
free(footers[0]);
free(footers);
}
free(align);
}
/* the end */
| [
"anjb@qkjr.com.cn"
] | anjb@qkjr.com.cn |
92008fedb78faeee246cb6a7ab8842922b50270b | 8915dc8cc5d375e5788813a36de316067bd90fc9 | /server_c/client.c | 52d13ca8ae9195ceca3ce859d3f0b93d1ce5e1a9 | [] | no_license | djoshuamartinez/nonsense | 020491b7ac39c815b08e8702915901b2c9d66014 | ad69251f63deb1d35169eedfc7ecd852653b1fe7 | refs/heads/master | 2020-04-08T20:44:25.781286 | 2018-11-29T20:36:48 | 2018-11-29T20:36:48 | 159,712,894 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 859 | c | #include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#define PORT 8080
int main(){
int sock = 0;
long valread;
struct sockaddr_in serv_addr;
char *hi = "hola";
char buffer[1024] = {0};
if((sock=socket(AF_INET, SOCK_STREAM, 0))<0){
printf("Socket not created");
return -1;
}
memset(&serv_addr, '\0', sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(PORT);
if(inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr)<=0){
printf("invalid address");
return -1;
}
if(connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr))<0){
printf("Connection failed");
return -1;
}
send(sock, hi, strlen(hi), 0);
valread = read(sock, buffer, 1024);
printf("%s", buffer);
return 0;
}
| [
"djoshuamartinezpineda@gmail.com"
] | djoshuamartinezpineda@gmail.com |
5d323e32a133f3d075d53b0fc05eafd65dd36594 | 57fe22142baa5006518a6c85caa7765acf97b9be | /015_testPalindromo/item_type.h | 6663f62f24a62ba0c551f982b93f1a5520fb058b | [] | no_license | EngTarcisioSm/CppLearn | cd8f463813585fffcf05009ae95892c830e4c37d | 96d9e5668fefb3a0720ebfa4beb5d9258f5e917e | refs/heads/main | 2023-03-31T07:14:14.666453 | 2021-03-25T09:03:56 | 2021-03-25T09:03:56 | 342,169,126 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 77 | h | #ifndef ITEM_TYPE_H
#define ITEM_TYPE_H
typedef char ItemType;
#endif | [
"dev.engtsm@gmail.com"
] | dev.engtsm@gmail.com |
17a2b9722a256d13fe1efaf105b718cbbe9eb8bf | c181bbf80e76ba6ea59fb2c9b4d9f6bd0941b28d | /2/rush00/ft_putchar.c | c7146741adeb62e52836b5d1d34a4c261518e2af | [] | no_license | franco15/piscine | fe84ced8718782b305501b52015df44a3e6a8349 | d2e5c606298d20f2f16f505a5f7f5214d9d3ce97 | refs/heads/master | 2021-01-23T07:26:11.280081 | 2017-02-03T16:42:56 | 2017-02-03T16:42:56 | 80,490,578 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 959 | c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfranco- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/14 16:20:25 by lfranco- #+# #+# */
/* Updated: 2017/01/14 16:20:33 by lfranco- ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
| [
"luis_fm_95@live.com.mx"
] | luis_fm_95@live.com.mx |
e29bc9e42c7189e0be728f916a71ad6db4a03534 | 253617c79cad6298e61350eec261d287547ae891 | /ows/ows.h | e1fbbb2f27240d7d341c19b99a1a286b265982c5 | [] | no_license | ken1336/Web-StreamingEX-via-FFmpeg | d2eb05bc48e36c2a110c1b2e02aa9fa0e6c17745 | 7f2e57c24e86017a684c2a33f33df07e98501992 | refs/heads/master | 2020-04-22T03:55:04.290754 | 2019-04-04T13:16:00 | 2019-04-04T13:16:00 | 170,105,531 | 0 | 0 | null | null | null | null | UHC | C | false | false | 4,019 | h | #pragma once
extern "C" //FFmpeg가 C라이브러리이기 때문에 이부분이 필요하다.
{
#include "libavcodec/avcodec.h"
#include "libavdevice\avdevice.h"
#include "libavfilter\avfilter.h"
#include "libavformat\avformat.h"
#include "libavutil\avutil.h"
#include "libpostproc\postprocess.h"
#include "libswresample\swresample.h"
#include "libswscale\swscale.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/timestamp.h"
#include "libavformat/avio.h""
#include "libavutil/file.h"
#include "SDL/SDL.h"
#include "SDL/SDL_thread.h"
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include<stdint.h>
#include"net.h"
#include"thread_m.h"
#include"log.h"
#define OWS_EXPORT __declspec(dllexport)
#define __INT_E int __stdcall
#define __CHARS_E char* __stdcall
#define DEFAULT_BUFFER_SIZE 4*1024
#define DEFAULT_STREAM_BUFFER_SIZE 32*1024*1024
enum OWSType {
FILE_IO = 0,
TCP_IO
};
typedef struct In_packet {
uint8_t *back_buffer = NULL;
uint8_t *main_buffer = NULL;
uint8_t **buffer_ref = NULL;
int seek_point = 0;
int size;
}in_packet;
typedef struct DecodeContext {
OWSType IOType;
int(*read_packet)(void *opaque, uint8_t *buf, int buf_size);
AVFormatContext *in_format_context = NULL;
AVCodecContext *decode_context = NULL;
AVCodec *decoder = NULL;
AVPacket input_packet;
AVFrame *decode_out_frame = NULL;
int got_frame;
int vstream_idx = -1;
int astream_idx = -1;
}DecodeContext;
typedef struct EncodeContext {
AVFormatContext *out_format_context = NULL;
AVCodec *encoder = NULL;
AVCodecContext *encode_context = NULL;
AVOutputFormat * out_format = NULL;
AVStream * out_stream = NULL;
AVPacket *output_packet = NULL;
void* output_stream = NULL;
}EncodeContext;
typedef struct SDLContext {
SDL_Event event;
SDL_Window *screen = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture *texture = NULL;
Uint8 *yPlane, *uPlane, *vPlane;
size_t yPlaneSz, uvPlaneSz;
int uvPitch;
struct SwsContext *sws_ctx = NULL;
}SDLContext;
typedef struct StreamingContext {
void* input_stream = NULL;
unsigned int context_id;
unsigned int threadID;
//
In_packet in_packet;
//Decode proc properties
DecodeContext decode_ctx;
//Input proc properties
tcpio_stream* stream = NULL;
AVIOContext *avio_ctx = NULL;
uint8_t *avio_ctx_buffer = NULL;
size_t avio_ctx_buffer_size = DEFAULT_STREAM_BUFFER_SIZE;
size_t buffer_size = DEFAULT_BUFFER_SIZE;
struct buffer_data bd = { 0 };
//Encode proc properties
EncodeContext encode_ctx;
//SDL properties
SDLContext sdl_ctx;
};
extern "C"
{
OWS_EXPORT __CHARS_E text_out(char* str);
OWS_EXPORT __INT_E math_add1(int a, int b);
OWS_EXPORT __CHARS_E text(char* str);
OWS_EXPORT __INT_E start_main_thread();
OWS_EXPORT __INT_E print_test();
OWS_EXPORT __INT_E reset_buffer_index();
}
int init_context(StreamingContext *s_cxt);
int stream_proc(void* args);
int read_packet(void *opaque, uint8_t *buf, int buf_size);
//int read_packet(void *opaque, uint8_t *buf, int buf_size)
//{
//
//
// struct tcpio_stream *bd = (tcpio_stream *)opaque;
// //printf("buffer ptr: %d buffer size: %d buf_size:%d\n", bd->buffer->ptr, bd->buffer->size,buf_size);
// buf_size = FFMIN(buf_size, bd->buffer->size);
// if (!buf_size)
// return AVERROR_EOF;
// printf("ptr:%p pre:%p size:%d buf_size: %d\n", bd->buffer->ptr, bd->buffer->pre, bd->buffer->size, buf_size);
// if (recv(bd->socket, (char*)bd->buffer->ptr, buf_size, 0) <= 0) {
// return 0;
// }
// /* copy internal buffer data to buf */
// memcpy(buf, bd->buffer->ptr, buf_size);
// bd->buffer->ptr += buf_size;
// bd->buffer->size -= buf_size;
// if (bd->buffer->size <= 0) {
//
// printf("buffer ptr move to pre");
// bd->buffer->ptr -= 32 * 1024 * 1024;
// printf("move ptr: %p -> %p\n", bd->buffer->ptr, bd->buffer->pre);
// bd->buffer->size = 32 * 1024 * 1024;
// }
// return buf_size;
//} | [
"ken1336@naver.com"
] | ken1336@naver.com |
2005de65af4d92b9fcc7d7ec870fefb318e299fd | e50723f40d0fbfa6e00ba0a43d20188469d33787 | /projeto/TCC/arquivosH/estatistica.h | 48965139b4fcb6e757386dd3d7eab96423c5eb7a | [] | no_license | khouri/TCC | 98ff533cb57f1e1ae7803c7e5f2137484fa386a3 | cc87154d8cda3b2176796ea9260ab7e0c1c0dd64 | refs/heads/master | 2020-04-15T22:42:16.621567 | 2019-01-10T15:25:52 | 2019-01-10T15:25:52 | 165,083,087 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 2,575 | h | /*******************************************************************************************/
/*******************************************************************************************/
/*************************Arquivo header do módulo de estatisticas**************************/
/*******************************************************************************************/
/*******************************************************************************************/
/***************Conteúdo: função que calcula histograma, funções auxiliares para************/
/***************calcular o histograma e uma struct que representa um histograma*************/
/*******************************************************************************************/
/***************Autor: Adilson Lopes Khouri*************************************************/
/*******************************************************************************************/
/*******************************************************************************************/
#include "../arquivosH/matematicaVetorial.h"
/*---------------------Definir intervalo entre barras do histograma-----------------------*/
/*Calcula a largura do gráfico*/
double dominioGrafico(double inicio, double fim);
/*Calcula a largura de uma barra do histograma.*/
double larguraBarraHistograma(double inicioGrafico, double fimGrafico, int numBarras);
/*Retorna os intervalos entre barras do histograma a ser plotado.*/
double * intervaloBarras(int NumBarras, double inicioIntervalo, double fimintervalo);
/*---------------------Definir intervalo entre barras do histograma-----------------------*/
/*--------------------------Utiliza a estrutura de histograma----------------------------*/
//Estrutura que representa um histograma
typedef struct
{
int tamanho;//Tamanho do array.
double * intervalos;//Intervalos em x entre barras.
double * frequencia;//Frequencia dos pontos nas barras.
int numPontos;
}histograma;
/*Aloca memória para a struct histograma.*/
histograma * inicializaHistograma(int numPontos, int numBarras);
/*Libera memória de um histograma.*/
void freeHistograma(histograma * liberar);
/*Função que calcula as frequências dos números de pontos.*/
histograma * calculaFrequencia(double * pontos, int nPontos,
int nBarras, int inicio, int fim);
/*Calcula a frequência relativa do histograma.*/
void frequenciaRelativa(histograma * h);
/*--------------------------Utiliza a estrutura de histograma----------------------------*/
| [
"adilson@nuvemshop.com.br"
] | adilson@nuvemshop.com.br |
992e6d2504a2842c1f80b5d932a39618909d6317 | 26387121e1bf0318ff04383fce7a38948aba9cf0 | /extras/ds18b20/ds18b20.c | e62011d6a5b4ba7660375ee0bc19f4938ee6a707 | [
"BSD-3-Clause"
] | permissive | hmc93/TFGdeHector | 32c8159310630305f4cfc0469127489d3680b4e5 | c943fa584b48f652103a53d6c647c211485b5560 | refs/heads/master | 2020-03-21T18:37:58.724915 | 2018-07-14T11:44:09 | 2018-07-14T11:44:09 | 138,903,695 | 0 | 1 | BSD-3-Clause | 2020-03-07T09:54:27 | 2018-06-27T16:00:34 | C | UTF-8 | C | false | false | 6,769 | c | #include "FreeRTOS.h"
#include "task.h"
#include "math.h"
#include "ds18b20.h"
#define DS18B20_WRITE_SCRATCHPAD 0x4E
#define DS18B20_READ_SCRATCHPAD 0xBE
#define DS18B20_COPY_SCRATCHPAD 0x48
#define DS18B20_READ_EEPROM 0xB8
#define DS18B20_READ_PWRSUPPLY 0xB4
#define DS18B20_SEARCHROM 0xF0
#define DS18B20_SKIP_ROM 0xCC
#define DS18B20_READROM 0x33
#define DS18B20_MATCHROM 0x55
#define DS18B20_ALARMSEARCH 0xEC
#define DS18B20_CONVERT_T 0x44
#define os_sleep_ms(x) vTaskDelay(((x) + portTICK_PERIOD_MS - 1) / portTICK_PERIOD_MS)
#define DS18B20_FAMILY_ID 0x28
#define DS18S20_FAMILY_ID 0x10
#ifdef DS18B20_DEBUG
#define debug(fmt, ...) printf("%s" fmt "\n", "DS18B20: ", ## __VA_ARGS__);
#else
#define debug(fmt, ...)
#endif
uint8_t ds18b20_read_all(uint8_t pin, ds_sensor_t *result) {
onewire_addr_t addr;
onewire_search_t search;
uint8_t sensor_id = 0;
onewire_search_start(&search);
while ((addr = onewire_search_next(&search, pin)) != ONEWIRE_NONE) {
uint8_t crc = onewire_crc8((uint8_t *)&addr, 7);
if (crc != (addr >> 56)){
debug("CRC check failed: %02X %02X\n", (unsigned)(addr >> 56), crc);
return 0;
}
onewire_reset(pin);
onewire_select(pin, addr);
onewire_write(pin, DS18B20_CONVERT_T);
onewire_power(pin);
vTaskDelay(750 / portTICK_PERIOD_MS);
onewire_reset(pin);
onewire_select(pin, addr);
onewire_write(pin, DS18B20_READ_SCRATCHPAD);
uint8_t get[10];
for (int k=0;k<9;k++){
get[k]=onewire_read(pin);
}
//debug("\n ScratchPAD DATA = %X %X %X %X %X %X %X %X %X\n",get[8],get[7],get[6],get[5],get[4],get[3],get[2],get[1],get[0]);
crc = onewire_crc8(get, 8);
if (crc != get[8]){
debug("CRC check failed: %02X %02X\n", get[8], crc);
return 0;
}
uint8_t temp_msb = get[1]; // Sign byte + lsbit
uint8_t temp_lsb = get[0]; // Temp data plus lsb
uint16_t temp = temp_msb << 8 | temp_lsb;
float temperature;
temperature = (temp * 625.0)/10000;
//debug("Got a DS18B20 Reading: %d.%02d\n", (int)temperature, (int)(temperature - (int)temperature) * 100);
result[sensor_id].id = sensor_id;
result[sensor_id].value = temperature;
sensor_id++;
}
return sensor_id;
}
float ds18b20_read_single(uint8_t pin) {
onewire_reset(pin);
onewire_skip_rom(pin);
onewire_write(pin, DS18B20_CONVERT_T);
onewire_power(pin);
vTaskDelay(750 / portTICK_PERIOD_MS);
onewire_reset(pin);
onewire_skip_rom(pin);
onewire_write(pin, DS18B20_READ_SCRATCHPAD);
uint8_t get[10];
for (int k=0;k<9;k++){
get[k]=onewire_read(pin);
}
//debug("\n ScratchPAD DATA = %X %X %X %X %X %X %X %X %X\n",get[8],get[7],get[6],get[5],get[4],get[3],get[2],get[1],get[0]);
uint8_t crc = onewire_crc8(get, 8);
if (crc != get[8]){
debug("CRC check failed: %02X %02X", get[8], crc);
return 0;
}
uint8_t temp_msb = get[1]; // Sign byte + lsbit
uint8_t temp_lsb = get[0]; // Temp data plus lsb
uint16_t temp = temp_msb << 8 | temp_lsb;
float temperature;
temperature = (temp * 625.0)/10000;
return temperature;
//debug("Got a DS18B20 Reading: %d.%02d\n", (int)temperature, (int)(temperature - (int)temperature) * 100);
}
bool ds18b20_measure(int pin, ds18b20_addr_t addr, bool wait) {
if (!onewire_reset(pin)) {
return false;
}
if (addr == DS18B20_ANY) {
onewire_skip_rom(pin);
} else {
onewire_select(pin, addr);
}
taskENTER_CRITICAL();
onewire_write(pin, DS18B20_CONVERT_T);
// For parasitic devices, power must be applied within 10us after issuing
// the convert command.
onewire_power(pin);
taskEXIT_CRITICAL();
if (wait) {
os_sleep_ms(750);
onewire_depower(pin);
}
return true;
}
bool ds18b20_read_scratchpad(int pin, ds18b20_addr_t addr, uint8_t *buffer) {
uint8_t crc;
uint8_t expected_crc;
if (!onewire_reset(pin)) {
return false;
}
if (addr == DS18B20_ANY) {
onewire_skip_rom(pin);
} else {
onewire_select(pin, addr);
}
onewire_write(pin, DS18B20_READ_SCRATCHPAD);
for (int i = 0; i < 8; i++) {
buffer[i] = onewire_read(pin);
}
crc = onewire_read(pin);
expected_crc = onewire_crc8(buffer, 8);
if (crc != expected_crc) {
debug("CRC check failed reading scratchpad: %02x %02x %02x %02x %02x %02x %02x %02x : %02x (expected %02x)\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], crc, expected_crc);
return false;
}
return true;
}
float ds18b20_read_temperature(int pin, ds18b20_addr_t addr) {
uint8_t scratchpad[8];
int16_t temp;
if (!ds18b20_read_scratchpad(pin, addr, scratchpad)) {
return NAN;
}
temp = scratchpad[1] << 8 | scratchpad[0];
float res;
if ((uint8_t)addr == DS18B20_FAMILY_ID) {
res = ((float)temp * 625.0)/10000;
}
else {
temp = ((temp & 0xfffe) << 3) + (16 - scratchpad[6]) - 4;
res = ((float)temp * 625.0)/10000 - 0.25;
}
return res;
}
float ds18b20_measure_and_read(int pin, ds18b20_addr_t addr) {
if (!ds18b20_measure(pin, addr, true)) {
return NAN;
}
return ds18b20_read_temperature(pin, addr);
}
bool ds18b20_measure_and_read_multi(int pin, ds18b20_addr_t *addr_list, int addr_count, float *result_list) {
if (!ds18b20_measure(pin, DS18B20_ANY, true)) {
for (int i=0; i < addr_count; i++) {
result_list[i] = NAN;
}
return false;
}
return ds18b20_read_temp_multi(pin, addr_list, addr_count, result_list);
}
int ds18b20_scan_devices(int pin, ds18b20_addr_t *addr_list, int addr_count) {
onewire_search_t search;
onewire_addr_t addr;
int found = 0;
onewire_search_start(&search);
while ((addr = onewire_search_next(&search, pin)) != ONEWIRE_NONE) {
uint8_t family_id = (uint8_t)addr;
if (family_id == DS18B20_FAMILY_ID || family_id == DS18S20_FAMILY_ID) {
if (found < addr_count) {
addr_list[found] = addr;
}
found++;
}
}
return found;
}
bool ds18b20_read_temp_multi(int pin, ds18b20_addr_t *addr_list, int addr_count, float *result_list) {
bool result = true;
for (int i = 0; i < addr_count; i++) {
result_list[i] = ds18b20_read_temperature(pin, addr_list[i]);
if (isnan(result_list[i])) {
result = false;
}
}
return result;
}
| [
"hector.carretero.carmona@gmail.com"
] | hector.carretero.carmona@gmail.com |
180611549ec84002f32c2ae067bce25686e76d88 | 5c255f911786e984286b1f7a4e6091a68419d049 | /code/917dfe75-6840-499a-9c7d-a174c807d5be.c | 8b11afd1f8b63078b273f5d954c73fbb5b199142 | [] | no_license | nmharmon8/Deep-Buffer-Overflow-Detection | 70fe02c8dc75d12e91f5bc4468cf260e490af1a4 | e0c86210c86afb07c8d4abcc957c7f1b252b4eb2 | refs/heads/master | 2021-09-11T19:09:59.944740 | 2018-04-06T16:26:34 | 2018-04-06T16:26:34 | 125,521,331 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 213 | c | #include <stdio.h>
int main() {
int i=4;
int j=14;
int k;
int l;
k = 53;
l = 64;
k = i/j;
l = i%j;
l = l/j;
k = k-j*i;
printf("vulnerability");
printf("%d\n",l);
return 0;
}
| [
"nharmon8@gmail.com"
] | nharmon8@gmail.com |
db145690c1f140938f3132496efc05f49418293d | a1e5a039507518bdeabb32ab7b4cc7f8bb198e38 | /platform/shared/ruby/ext/socket/raddrinfo.c | 67bc9c2a97d15df4ad55d3651bcff719667b7f4e | [
"GPL-2.0-only",
"MIT"
] | permissive | tauplatform/tau | 45a7ef9dcc1d0056df7fa91e008d2739cc1a8be4 | e5391aab5acbd6fed6d4f886e217cc304b816af8 | refs/heads/master | 2020-12-26T02:59:15.426685 | 2018-03-24T11:44:30 | 2018-03-24T11:44:30 | 39,137,782 | 9 | 0 | MIT | 2018-03-24T11:44:31 | 2015-07-15T13:16:58 | C | UTF-8 | C | false | false | 77,378 | c | /************************************************
raddrinfo.c -
created at: Thu Mar 31 12:21:29 JST 1994
Copyright (C) 1993-2007 Yukihiro Matsumoto
************************************************/
#include "rubysocket.h"
#if defined(INET6) && (defined(LOOKUP_ORDER_HACK_INET) || defined(LOOKUP_ORDER_HACK_INET6))
#define LOOKUP_ORDERS (sizeof(lookup_order_table) / sizeof(lookup_order_table[0]))
static const int lookup_order_table[] = {
#if defined(LOOKUP_ORDER_HACK_INET)
PF_INET, PF_INET6, PF_UNSPEC,
#elif defined(LOOKUP_ORDER_HACK_INET6)
PF_INET6, PF_INET, PF_UNSPEC,
#else
/* should not happen */
#endif
};
static int
ruby_getaddrinfo(const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
struct addrinfo tmp_hints;
int i, af, error;
if (hints->ai_family != PF_UNSPEC) {
return getaddrinfo(nodename, servname, hints, res);
}
for (i = 0; i < LOOKUP_ORDERS; i++) {
af = lookup_order_table[i];
MEMCPY(&tmp_hints, hints, struct addrinfo, 1);
tmp_hints.ai_family = af;
error = getaddrinfo(nodename, servname, &tmp_hints, res);
if (error) {
if (tmp_hints.ai_family == PF_UNSPEC) {
break;
}
}
else {
break;
}
}
return error;
}
#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo((node),(serv),(hints),(res))
#endif
#if defined(_AIX)
static int
ruby_getaddrinfo__aix(const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
int error = getaddrinfo(nodename, servname, hints, res);
struct addrinfo *r;
if (error)
return error;
for (r = *res; r != NULL; r = r->ai_next) {
if (r->ai_addr->sa_family == 0)
r->ai_addr->sa_family = r->ai_family;
if (r->ai_addr->sa_len == 0)
r->ai_addr->sa_len = r->ai_addrlen;
}
return 0;
}
#undef getaddrinfo
#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__aix((node),(serv),(hints),(res))
static int
ruby_getnameinfo__aix(const struct sockaddr *sa, size_t salen,
char *host, size_t hostlen,
char *serv, size_t servlen, int flags)
{
struct sockaddr_in6 *sa6;
u_int32_t *a6;
if (sa->sa_family == AF_INET6) {
sa6 = (struct sockaddr_in6 *)sa;
a6 = sa6->sin6_addr.u6_addr.u6_addr32;
if (a6[0] == 0 && a6[1] == 0 && a6[2] == 0 && a6[3] == 0) {
strncpy(host, "::", hostlen);
snprintf(serv, servlen, "%d", sa6->sin6_port);
return 0;
}
}
return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
}
#undef getnameinfo
#define getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) \
ruby_getnameinfo__aix((sa), (salen), (host), (hostlen), (serv), (servlen), (flags))
#endif
static int str_is_number(const char *);
#if defined(__APPLE__)
static int
ruby_getaddrinfo__darwin(const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
/* fix [ruby-core:29427] */
const char *tmp_servname;
struct addrinfo tmp_hints;
int error;
tmp_servname = servname;
MEMCPY(&tmp_hints, hints, struct addrinfo, 1);
if (nodename && servname) {
if (str_is_number(tmp_servname) && atoi(servname) == 0) {
tmp_servname = NULL;
#ifdef AI_NUMERICSERV
if (tmp_hints.ai_flags) tmp_hints.ai_flags &= ~AI_NUMERICSERV;
#endif
}
}
error = getaddrinfo(nodename, tmp_servname, &tmp_hints, res);
if (error == 0) {
/* [ruby-dev:23164] */
struct addrinfo *r;
r = *res;
while (r) {
if (! r->ai_socktype) r->ai_socktype = hints->ai_socktype;
if (! r->ai_protocol) {
if (r->ai_socktype == SOCK_DGRAM) {
r->ai_protocol = IPPROTO_UDP;
}
else if (r->ai_socktype == SOCK_STREAM) {
r->ai_protocol = IPPROTO_TCP;
}
}
r = r->ai_next;
}
}
return error;
}
#undef getaddrinfo
#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__darwin((node),(serv),(hints),(res))
#endif
#ifndef GETADDRINFO_EMU
struct getaddrinfo_arg
{
const char *node;
const char *service;
const struct addrinfo *hints;
struct addrinfo **res;
};
#ifdef HAVE_INET_PTON
static int
parse_numeric_port(const char *service, int *portp)
{
unsigned long u;
if (!service) {
*portp = 0;
return 1;
}
if (strspn(service, "0123456789") != strlen(service))
return 0;
errno = 0;
u = STRTOUL(service, NULL, 10);
if (errno)
return 0;
if (0x10000 <= u)
return 0;
*portp = (int)u;
return 1;
}
#endif
static void *
nogvl_getaddrinfo(void *arg)
{
int ret;
struct getaddrinfo_arg *ptr = arg;
ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
#ifdef __linux__
/* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
* it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
*/
if (ret == EAI_SYSTEM && errno == ENOENT)
ret = EAI_NONAME;
#endif
return (void *)(VALUE)ret;
}
#endif
static int
numeric_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res)
{
#ifdef HAVE_INET_PTON
# if defined __MINGW64__
# define inet_pton(f,s,d) rb_w32_inet_pton(f,s,d)
# endif
int port;
if (node && parse_numeric_port(service, &port)) {
static const struct {
int socktype;
int protocol;
} list[] = {
{ SOCK_STREAM, IPPROTO_TCP },
{ SOCK_DGRAM, IPPROTO_UDP },
{ SOCK_RAW, 0 }
};
struct addrinfo *ai = NULL;
int hint_family = hints ? hints->ai_family : PF_UNSPEC;
int hint_socktype = hints ? hints->ai_socktype : 0;
int hint_protocol = hints ? hints->ai_protocol : 0;
char ipv4addr[4];
#ifdef AF_INET6
char ipv6addr[16];
if ((hint_family == PF_UNSPEC || hint_family == PF_INET6) &&
strspn(node, "0123456789abcdefABCDEF.:") == strlen(node) &&
inet_pton(AF_INET6, node, ipv6addr)) {
int i;
for (i = numberof(list)-1; 0 <= i; i--) {
if ((hint_socktype == 0 || hint_socktype == list[i].socktype) &&
(hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) {
struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo));
struct sockaddr_in6 *sa = xmalloc(sizeof(struct sockaddr_in6));
INIT_SOCKADDR_IN6(sa, sizeof(struct sockaddr_in6));
memcpy(&sa->sin6_addr, ipv6addr, sizeof(ipv6addr));
sa->sin6_port = htons(port);
ai0->ai_family = PF_INET6;
ai0->ai_socktype = list[i].socktype;
ai0->ai_protocol = hint_protocol ? hint_protocol : list[i].protocol;
ai0->ai_addrlen = sizeof(struct sockaddr_in6);
ai0->ai_addr = (struct sockaddr *)sa;
ai0->ai_canonname = NULL;
ai0->ai_next = ai;
ai = ai0;
}
}
}
else
#endif
if ((hint_family == PF_UNSPEC || hint_family == PF_INET) &&
strspn(node, "0123456789.") == strlen(node) &&
inet_pton(AF_INET, node, ipv4addr)) {
int i;
for (i = numberof(list)-1; 0 <= i; i--) {
if ((hint_socktype == 0 || hint_socktype == list[i].socktype) &&
(hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) {
struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo));
struct sockaddr_in *sa = xmalloc(sizeof(struct sockaddr_in));
INIT_SOCKADDR_IN(sa, sizeof(struct sockaddr_in));
memcpy(&sa->sin_addr, ipv4addr, sizeof(ipv4addr));
sa->sin_port = htons(port);
ai0->ai_family = PF_INET;
ai0->ai_socktype = list[i].socktype;
ai0->ai_protocol = hint_protocol ? hint_protocol : list[i].protocol;
ai0->ai_addrlen = sizeof(struct sockaddr_in);
ai0->ai_addr = (struct sockaddr *)sa;
ai0->ai_canonname = NULL;
ai0->ai_next = ai;
ai = ai0;
}
}
}
if (ai) {
*res = ai;
return 0;
}
}
#endif
return EAI_FAIL;
}
int
rb_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct rb_addrinfo **res)
{
struct addrinfo *ai;
int ret;
int allocated_by_malloc = 0;
ret = numeric_getaddrinfo(node, service, hints, &ai);
if (ret == 0)
allocated_by_malloc = 1;
else {
#ifdef GETADDRINFO_EMU
ret = getaddrinfo(node, service, hints, &ai);
#else
struct getaddrinfo_arg arg;
MEMZERO(&arg, struct getaddrinfo_arg, 1);
arg.node = node;
arg.service = service;
arg.hints = hints;
arg.res = &ai;
ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
#endif
}
if (ret == 0) {
*res = (struct rb_addrinfo *)xmalloc(sizeof(struct rb_addrinfo));
(*res)->allocated_by_malloc = allocated_by_malloc;
(*res)->ai = ai;
}
return ret;
}
void
rb_freeaddrinfo(struct rb_addrinfo *ai)
{
if (!ai->allocated_by_malloc)
freeaddrinfo(ai->ai);
else {
struct addrinfo *ai1, *ai2;
ai1 = ai->ai;
while (ai1) {
ai2 = ai1->ai_next;
xfree(ai1->ai_addr);
xfree(ai1);
ai1 = ai2;
}
}
xfree(ai);
}
#ifndef GETADDRINFO_EMU
struct getnameinfo_arg
{
const struct sockaddr *sa;
socklen_t salen;
int flags;
char *host;
size_t hostlen;
char *serv;
size_t servlen;
};
static void *
nogvl_getnameinfo(void *arg)
{
struct getnameinfo_arg *ptr = arg;
return (void *)(VALUE)getnameinfo(ptr->sa, ptr->salen,
ptr->host, (socklen_t)ptr->hostlen,
ptr->serv, (socklen_t)ptr->servlen,
ptr->flags);
}
#endif
int
rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen,
char *serv, size_t servlen, int flags)
{
#ifdef GETADDRINFO_EMU
return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
#else
struct getnameinfo_arg arg;
int ret;
arg.sa = sa;
arg.salen = salen;
arg.host = host;
arg.hostlen = hostlen;
arg.serv = serv;
arg.servlen = servlen;
arg.flags = flags;
ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getnameinfo, &arg, RUBY_UBF_IO, 0);
return ret;
#endif
}
static void
make_ipaddr0(struct sockaddr *addr, socklen_t addrlen, char *buf, size_t buflen)
{
int error;
error = rb_getnameinfo(addr, addrlen, buf, buflen, NULL, 0, NI_NUMERICHOST);
if (error) {
rsock_raise_socket_error("getnameinfo", error);
}
}
VALUE
rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen)
{
char hbuf[1024];
make_ipaddr0(addr, addrlen, hbuf, sizeof(hbuf));
return rb_str_new2(hbuf);
}
static void
make_inetaddr(unsigned int host, char *buf, size_t buflen)
{
struct sockaddr_in sin;
INIT_SOCKADDR_IN(&sin, sizeof(sin));
sin.sin_addr.s_addr = host;
make_ipaddr0((struct sockaddr*)&sin, sizeof(sin), buf, buflen);
}
static int
str_is_number(const char *p)
{
char *ep;
if (!p || *p == '\0')
return 0;
ep = NULL;
(void)STRTOUL(p, &ep, 10);
if (ep && *ep == '\0')
return 1;
else
return 0;
}
#define str_equal(ptr, len, name) \
((ptr)[0] == name[0] && \
rb_strlen_lit(name) == (len) && memcmp(ptr, name, len) == 0)
#define SafeStringValueCStr(v) do {\
StringValueCStr(v);\
rb_check_safe_obj(v);\
} while(0)
static char*
host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
{
if (NIL_P(host)) {
return NULL;
}
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
unsigned int i = NUM2UINT(host);
make_inetaddr(htonl(i), hbuf, hbuflen);
if (flags_ptr) *flags_ptr |= AI_NUMERICHOST;
return hbuf;
}
else {
const char *name;
size_t len;
SafeStringValueCStr(host);
RSTRING_GETMEM(host, name, len);
if (!len || str_equal(name, len, "<any>")) {
make_inetaddr(INADDR_ANY, hbuf, hbuflen);
if (flags_ptr) *flags_ptr |= AI_NUMERICHOST;
}
else if (str_equal(name, len, "<broadcast>")) {
make_inetaddr(INADDR_BROADCAST, hbuf, hbuflen);
if (flags_ptr) *flags_ptr |= AI_NUMERICHOST;
}
else if (len >= hbuflen) {
rb_raise(rb_eArgError, "hostname too long (%"PRIuSIZE")",
len);
}
else {
memcpy(hbuf, name, len);
hbuf[len] = '\0';
}
return hbuf;
}
}
static char*
port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr)
{
if (NIL_P(port)) {
return 0;
}
else if (FIXNUM_P(port)) {
snprintf(pbuf, pbuflen, "%ld", FIX2LONG(port));
#ifdef AI_NUMERICSERV
if (flags_ptr) *flags_ptr |= AI_NUMERICSERV;
#endif
return pbuf;
}
else {
const char *serv;
size_t len;
SafeStringValueCStr(port);
RSTRING_GETMEM(port, serv, len);
if (len >= pbuflen) {
rb_raise(rb_eArgError, "service name too long (%"PRIuSIZE")",
len);
}
memcpy(pbuf, serv, len);
pbuf[len] = '\0';
return pbuf;
}
}
struct rb_addrinfo*
rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
{
struct rb_addrinfo* res = NULL;
char *hostp, *portp;
int error;
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
int additional_flags = 0;
hostp = host_str(host, hbuf, sizeof(hbuf), &additional_flags);
portp = port_str(port, pbuf, sizeof(pbuf), &additional_flags);
if (socktype_hack && hints->ai_socktype == 0 && str_is_number(portp)) {
hints->ai_socktype = SOCK_DGRAM;
}
hints->ai_flags |= additional_flags;
error = rb_getaddrinfo(hostp, portp, hints, &res);
if (error) {
if (hostp && hostp[strlen(hostp)-1] == '\n') {
rb_raise(rb_eSocket, "newline at the end of hostname");
}
rsock_raise_socket_error("getaddrinfo", error);
}
return res;
}
int
rsock_fd_family(int fd)
{
struct sockaddr sa = { 0 };
socklen_t sa_len = sizeof(sa);
if (fd < 0 || getsockname(fd, &sa, &sa_len) != 0 ||
(size_t)sa_len < offsetof(struct sockaddr, sa_family) + sizeof(sa.sa_family)) {
return AF_UNSPEC;
}
return sa.sa_family;
}
struct rb_addrinfo*
rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags)
{
struct addrinfo hints;
MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = family;
hints.ai_socktype = socktype;
hints.ai_flags = flags;
return rsock_getaddrinfo(host, port, &hints, 1);
}
VALUE
rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
{
VALUE family, port, addr1, addr2;
VALUE ary;
int error;
char hbuf[1024], pbuf[1024];
ID id;
id = rsock_intern_family(sockaddr->sa_family);
if (id) {
family = rb_str_dup(rb_id2str(id));
}
else {
sprintf(pbuf, "unknown:%d", sockaddr->sa_family);
family = rb_str_new2(pbuf);
}
addr1 = Qnil;
if (!norevlookup) {
error = rb_getnameinfo(sockaddr, sockaddrlen, hbuf, sizeof(hbuf),
NULL, 0, 0);
if (! error) {
addr1 = rb_str_new2(hbuf);
}
}
error = rb_getnameinfo(sockaddr, sockaddrlen, hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
rsock_raise_socket_error("getnameinfo", error);
}
addr2 = rb_str_new2(hbuf);
if (addr1 == Qnil) {
addr1 = addr2;
}
port = INT2FIX(atoi(pbuf));
ary = rb_ary_new3(4, family, port, addr1, addr2);
return ary;
}
#ifdef HAVE_SYS_UN_H
VALUE
rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len)
{
char *s, *e;
s = sockaddr->sun_path;
e = (char *)sockaddr + len;
while (s < e && *(e-1) == '\0')
e--;
if (s <= e)
return rb_str_new(s, e-s);
else
return rb_str_new2("");
}
VALUE
rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len)
{
return rb_assoc_new(rb_str_new2("AF_UNIX"),
rsock_unixpath_str(sockaddr, len));
}
socklen_t
rsock_unix_sockaddr_len(VALUE path)
{
#ifdef __linux__
if (RSTRING_LEN(path) == 0) {
/* autobind; see unix(7) for details. */
return (socklen_t) sizeof(sa_family_t);
}
else if (RSTRING_PTR(path)[0] == '\0') {
/* abstract namespace; see unix(7) for details. */
if (SOCKLEN_MAX - offsetof(struct sockaddr_un, sun_path) < (size_t)RSTRING_LEN(path))
rb_raise(rb_eArgError, "Linux abstract socket too long");
return (socklen_t) offsetof(struct sockaddr_un, sun_path) +
RSTRING_SOCKLEN(path);
}
else {
#endif
return (socklen_t) sizeof(struct sockaddr_un);
#ifdef __linux__
}
#endif
}
#endif
struct hostent_arg {
VALUE host;
struct rb_addrinfo* addr;
VALUE (*ipaddr)(struct sockaddr*, socklen_t);
};
static VALUE
make_hostent_internal(struct hostent_arg *arg)
{
VALUE host = arg->host;
struct addrinfo* addr = arg->addr->ai;
VALUE (*ipaddr)(struct sockaddr*, socklen_t) = arg->ipaddr;
struct addrinfo *ai;
struct hostent *h;
VALUE ary, names;
char **pch;
const char* hostp;
char hbuf[NI_MAXHOST];
ary = rb_ary_new();
if (addr->ai_canonname) {
hostp = addr->ai_canonname;
}
else {
hostp = host_str(host, hbuf, sizeof(hbuf), NULL);
}
rb_ary_push(ary, rb_str_new2(hostp));
if (addr->ai_canonname && strlen(addr->ai_canonname) < NI_MAXHOST &&
(h = gethostbyname(addr->ai_canonname))) {
names = rb_ary_new();
if (h->h_aliases != NULL) {
for (pch = h->h_aliases; *pch; pch++) {
rb_ary_push(names, rb_str_new2(*pch));
}
}
}
else {
names = rb_ary_new2(0);
}
rb_ary_push(ary, names);
rb_ary_push(ary, INT2NUM(addr->ai_family));
for (ai = addr; ai; ai = ai->ai_next) {
rb_ary_push(ary, (*ipaddr)(ai->ai_addr, ai->ai_addrlen));
}
return ary;
}
VALUE
rsock_freeaddrinfo(VALUE arg)
{
struct rb_addrinfo *addr = (struct rb_addrinfo *)arg;
rb_freeaddrinfo(addr);
return Qnil;
}
VALUE
rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t))
{
struct hostent_arg arg;
arg.host = host;
arg.addr = addr;
arg.ipaddr = ipaddr;
return rb_ensure(make_hostent_internal, (VALUE)&arg,
rsock_freeaddrinfo, (VALUE)addr);
}
typedef struct {
VALUE inspectname;
VALUE canonname;
int pfamily;
int socktype;
int protocol;
socklen_t sockaddr_len;
union_sockaddr addr;
} rb_addrinfo_t;
static void
addrinfo_mark(void *ptr)
{
rb_addrinfo_t *rai = ptr;
if (rai) {
rb_gc_mark(rai->inspectname);
rb_gc_mark(rai->canonname);
}
}
#define addrinfo_free RUBY_TYPED_DEFAULT_FREE
static size_t
addrinfo_memsize(const void *ptr)
{
return sizeof(rb_addrinfo_t);
}
static const rb_data_type_t addrinfo_type = {
"socket/addrinfo",
{addrinfo_mark, addrinfo_free, addrinfo_memsize,},
};
static VALUE
addrinfo_s_allocate(VALUE klass)
{
return TypedData_Wrap_Struct(klass, &addrinfo_type, 0);
}
#define IS_ADDRINFO(obj) rb_typeddata_is_kind_of((obj), &addrinfo_type)
static inline rb_addrinfo_t *
check_addrinfo(VALUE self)
{
return rb_check_typeddata(self, &addrinfo_type);
}
static rb_addrinfo_t *
get_addrinfo(VALUE self)
{
rb_addrinfo_t *rai = check_addrinfo(self);
if (!rai) {
rb_raise(rb_eTypeError, "uninitialized socket address");
}
return rai;
}
static rb_addrinfo_t *
alloc_addrinfo(void)
{
rb_addrinfo_t *rai = ZALLOC(rb_addrinfo_t);
rai->inspectname = Qnil;
rai->canonname = Qnil;
return rai;
}
static void
init_addrinfo(rb_addrinfo_t *rai, struct sockaddr *sa, socklen_t len,
int pfamily, int socktype, int protocol,
VALUE canonname, VALUE inspectname)
{
if ((socklen_t)sizeof(rai->addr) < len)
rb_raise(rb_eArgError, "sockaddr string too big");
memcpy((void *)&rai->addr, (void *)sa, len);
rai->sockaddr_len = len;
rai->pfamily = pfamily;
rai->socktype = socktype;
rai->protocol = protocol;
rai->canonname = canonname;
rai->inspectname = inspectname;
}
VALUE
rsock_addrinfo_new(struct sockaddr *addr, socklen_t len,
int family, int socktype, int protocol,
VALUE canonname, VALUE inspectname)
{
VALUE a;
rb_addrinfo_t *rai;
a = addrinfo_s_allocate(rb_cAddrinfo);
DATA_PTR(a) = rai = alloc_addrinfo();
init_addrinfo(rai, addr, len, family, socktype, protocol, canonname, inspectname);
return a;
}
static struct rb_addrinfo *
call_getaddrinfo(VALUE node, VALUE service,
VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
int socktype_hack)
{
struct addrinfo hints;
struct rb_addrinfo *res;
MEMZERO(&hints, struct addrinfo, 1);
hints.ai_family = NIL_P(family) ? PF_UNSPEC : rsock_family_arg(family);
if (!NIL_P(socktype)) {
hints.ai_socktype = rsock_socktype_arg(socktype);
}
if (!NIL_P(protocol)) {
hints.ai_protocol = NUM2INT(protocol);
}
if (!NIL_P(flags)) {
hints.ai_flags = NUM2INT(flags);
}
res = rsock_getaddrinfo(node, service, &hints, socktype_hack);
if (res == NULL)
rb_raise(rb_eSocket, "host not found");
return res;
}
static VALUE make_inspectname(VALUE node, VALUE service, struct addrinfo *res);
static void
init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service,
VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
VALUE inspectnode, VALUE inspectservice)
{
struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 1);
VALUE canonname;
VALUE inspectname = rb_str_equal(node, inspectnode) ? Qnil : make_inspectname(inspectnode, inspectservice, res->ai);
canonname = Qnil;
if (res->ai->ai_canonname) {
canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname);
OBJ_FREEZE(canonname);
}
init_addrinfo(rai, res->ai->ai_addr, res->ai->ai_addrlen,
NUM2INT(family), NUM2INT(socktype), NUM2INT(protocol),
canonname, inspectname);
rb_freeaddrinfo(res);
}
static VALUE
make_inspectname(VALUE node, VALUE service, struct addrinfo *res)
{
VALUE inspectname = Qnil;
if (res) {
/* drop redundant information which also shown in address:port part. */
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
int ret;
ret = rb_getnameinfo(res->ai_addr, res->ai_addrlen, hbuf,
sizeof(hbuf), pbuf, sizeof(pbuf),
NI_NUMERICHOST|NI_NUMERICSERV);
if (ret == 0) {
if (RB_TYPE_P(node, T_STRING) && strcmp(hbuf, RSTRING_PTR(node)) == 0)
node = Qnil;
if (RB_TYPE_P(service, T_STRING) && strcmp(pbuf, RSTRING_PTR(service)) == 0)
service = Qnil;
else if (RB_TYPE_P(service, T_FIXNUM) && atoi(pbuf) == FIX2INT(service))
service = Qnil;
}
}
if (RB_TYPE_P(node, T_STRING)) {
inspectname = rb_str_dup(node);
}
if (RB_TYPE_P(service, T_STRING)) {
if (NIL_P(inspectname))
inspectname = rb_sprintf(":%s", StringValueCStr(service));
else
rb_str_catf(inspectname, ":%s", StringValueCStr(service));
}
else if (RB_TYPE_P(service, T_FIXNUM) && FIX2INT(service) != 0)
{
if (NIL_P(inspectname))
inspectname = rb_sprintf(":%d", FIX2INT(service));
else
rb_str_catf(inspectname, ":%d", FIX2INT(service));
}
if (!NIL_P(inspectname)) {
OBJ_INFECT(inspectname, node);
OBJ_INFECT(inspectname, service);
OBJ_FREEZE(inspectname);
}
return inspectname;
}
static VALUE
addrinfo_firstonly_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags)
{
VALUE ret;
VALUE canonname;
VALUE inspectname;
struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
inspectname = make_inspectname(node, service, res->ai);
canonname = Qnil;
if (res->ai->ai_canonname) {
canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname);
OBJ_FREEZE(canonname);
}
ret = rsock_addrinfo_new(res->ai->ai_addr, res->ai->ai_addrlen,
res->ai->ai_family, res->ai->ai_socktype,
res->ai->ai_protocol,
canonname, inspectname);
rb_freeaddrinfo(res);
return ret;
}
static VALUE
addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags)
{
VALUE ret;
struct addrinfo *r;
VALUE inspectname;
struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
inspectname = make_inspectname(node, service, res->ai);
ret = rb_ary_new();
for (r = res->ai; r; r = r->ai_next) {
VALUE addr;
VALUE canonname = Qnil;
if (r->ai_canonname) {
canonname = rb_tainted_str_new_cstr(r->ai_canonname);
OBJ_FREEZE(canonname);
}
addr = rsock_addrinfo_new(r->ai_addr, r->ai_addrlen,
r->ai_family, r->ai_socktype, r->ai_protocol,
canonname, inspectname);
rb_ary_push(ret, addr);
}
rb_freeaddrinfo(res);
return ret;
}
#ifdef HAVE_SYS_UN_H
static void
init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
{
struct sockaddr_un un;
socklen_t len;
StringValue(path);
if (sizeof(un.sun_path) < (size_t)RSTRING_LEN(path))
rb_raise(rb_eArgError,
"too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
(size_t)RSTRING_LEN(path), sizeof(un.sun_path));
INIT_SOCKADDR_UN(&un, sizeof(struct sockaddr_un));
memcpy((void*)&un.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
len = rsock_unix_sockaddr_len(path);
init_addrinfo(rai, (struct sockaddr *)&un, len,
PF_UNIX, socktype, 0, Qnil, Qnil);
}
#endif
/*
* call-seq:
* Addrinfo.new(sockaddr) => addrinfo
* Addrinfo.new(sockaddr, family) => addrinfo
* Addrinfo.new(sockaddr, family, socktype) => addrinfo
* Addrinfo.new(sockaddr, family, socktype, protocol) => addrinfo
*
* returns a new instance of Addrinfo.
* The instance contains sockaddr, family, socktype, protocol.
* sockaddr means struct sockaddr which can be used for connect(2), etc.
* family, socktype and protocol are integers which is used for arguments of socket(2).
*
* sockaddr is specified as an array or a string.
* The array should be compatible to the value of IPSocket#addr or UNIXSocket#addr.
* The string should be struct sockaddr as generated by
* Socket.sockaddr_in or Socket.unpack_sockaddr_un.
*
* sockaddr examples:
* - ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"]
* - ["AF_INET6", 42304, "ip6-localhost", "::1"]
* - ["AF_UNIX", "/tmp/sock"]
* - Socket.sockaddr_in("smtp", "2001:DB8::1")
* - Socket.sockaddr_in(80, "172.18.22.42")
* - Socket.sockaddr_in(80, "www.ruby-lang.org")
* - Socket.sockaddr_un("/tmp/sock")
*
* In an AF_INET/AF_INET6 sockaddr array, the 4th element,
* numeric IP address, is used to construct socket address in the Addrinfo instance.
* If the 3rd element, textual host name, is non-nil, it is also recorded but used only for Addrinfo#inspect.
*
* family is specified as an integer to specify the protocol family such as Socket::PF_INET.
* It can be a symbol or a string which is the constant name
* with or without PF_ prefix such as :INET, :INET6, :UNIX, "PF_INET", etc.
* If omitted, PF_UNSPEC is assumed.
*
* socktype is specified as an integer to specify the socket type such as Socket::SOCK_STREAM.
* It can be a symbol or a string which is the constant name
* with or without SOCK_ prefix such as :STREAM, :DGRAM, :RAW, "SOCK_STREAM", etc.
* If omitted, 0 is assumed.
*
* protocol is specified as an integer to specify the protocol such as Socket::IPPROTO_TCP.
* It must be an integer, unlike family and socktype.
* If omitted, 0 is assumed.
* Note that 0 is reasonable value for most protocols, except raw socket.
*
*/
static VALUE
addrinfo_initialize(int argc, VALUE *argv, VALUE self)
{
rb_addrinfo_t *rai;
VALUE sockaddr_arg, sockaddr_ary, pfamily, socktype, protocol;
int i_pfamily, i_socktype, i_protocol;
struct sockaddr *sockaddr_ptr;
socklen_t sockaddr_len;
VALUE canonname = Qnil, inspectname = Qnil;
if (check_addrinfo(self))
rb_raise(rb_eTypeError, "already initialized socket address");
DATA_PTR(self) = rai = alloc_addrinfo();
rb_scan_args(argc, argv, "13", &sockaddr_arg, &pfamily, &socktype, &protocol);
i_pfamily = NIL_P(pfamily) ? PF_UNSPEC : rsock_family_arg(pfamily);
i_socktype = NIL_P(socktype) ? 0 : rsock_socktype_arg(socktype);
i_protocol = NIL_P(protocol) ? 0 : NUM2INT(protocol);
sockaddr_ary = rb_check_array_type(sockaddr_arg);
if (!NIL_P(sockaddr_ary)) {
VALUE afamily = rb_ary_entry(sockaddr_ary, 0);
int af;
StringValue(afamily);
if (rsock_family_to_int(RSTRING_PTR(afamily), RSTRING_LEN(afamily), &af) == -1)
rb_raise(rb_eSocket, "unknown address family: %s", StringValueCStr(afamily));
switch (af) {
case AF_INET: /* ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] */
#ifdef INET6
case AF_INET6: /* ["AF_INET6", 42304, "ip6-localhost", "::1"] */
#endif
{
VALUE service = rb_ary_entry(sockaddr_ary, 1);
VALUE nodename = rb_ary_entry(sockaddr_ary, 2);
VALUE numericnode = rb_ary_entry(sockaddr_ary, 3);
int flags;
service = INT2NUM(NUM2INT(service));
if (!NIL_P(nodename))
StringValue(nodename);
StringValue(numericnode);
flags = AI_NUMERICHOST;
#ifdef AI_NUMERICSERV
flags |= AI_NUMERICSERV;
#endif
init_addrinfo_getaddrinfo(rai, numericnode, service,
INT2NUM(i_pfamily ? i_pfamily : af), INT2NUM(i_socktype), INT2NUM(i_protocol),
INT2NUM(flags),
nodename, service);
break;
}
#ifdef HAVE_SYS_UN_H
case AF_UNIX: /* ["AF_UNIX", "/tmp/sock"] */
{
VALUE path = rb_ary_entry(sockaddr_ary, 1);
StringValue(path);
init_unix_addrinfo(rai, path, SOCK_STREAM);
break;
}
#endif
default:
rb_raise(rb_eSocket, "unexpected address family");
}
}
else {
StringValue(sockaddr_arg);
sockaddr_ptr = (struct sockaddr *)RSTRING_PTR(sockaddr_arg);
sockaddr_len = RSTRING_SOCKLEN(sockaddr_arg);
init_addrinfo(rai, sockaddr_ptr, sockaddr_len,
i_pfamily, i_socktype, i_protocol,
canonname, inspectname);
}
return self;
}
static int
get_afamily(struct sockaddr *addr, socklen_t len)
{
if ((socklen_t)((char*)&addr->sa_family + sizeof(addr->sa_family) - (char*)addr) <= len)
return addr->sa_family;
else
return AF_UNSPEC;
}
static int
ai_get_afamily(rb_addrinfo_t *rai)
{
return get_afamily(&rai->addr.addr, rai->sockaddr_len);
}
static VALUE
inspect_sockaddr(VALUE addrinfo, VALUE ret)
{
rb_addrinfo_t *rai = get_addrinfo(addrinfo);
union_sockaddr *sockaddr = &rai->addr;
socklen_t socklen = rai->sockaddr_len;
return rsock_inspect_sockaddr((struct sockaddr *)sockaddr, socklen, ret);
}
VALUE
rsock_inspect_sockaddr(struct sockaddr *sockaddr_arg, socklen_t socklen, VALUE ret)
{
union_sockaddr *sockaddr = (union_sockaddr *)sockaddr_arg;
if (socklen == 0) {
rb_str_cat2(ret, "empty-sockaddr");
}
else if ((long)socklen < ((char*)&sockaddr->addr.sa_family + sizeof(sockaddr->addr.sa_family)) - (char*)sockaddr)
rb_str_cat2(ret, "too-short-sockaddr");
else {
switch (sockaddr->addr.sa_family) {
case AF_UNSPEC:
{
rb_str_cat2(ret, "UNSPEC");
break;
}
case AF_INET:
{
struct sockaddr_in *addr;
int port;
addr = &sockaddr->in;
if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+0+1) <= socklen)
rb_str_catf(ret, "%d", ((unsigned char*)&addr->sin_addr)[0]);
else
rb_str_cat2(ret, "?");
if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+1+1) <= socklen)
rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[1]);
else
rb_str_cat2(ret, ".?");
if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+2+1) <= socklen)
rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[2]);
else
rb_str_cat2(ret, ".?");
if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+3+1) <= socklen)
rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[3]);
else
rb_str_cat2(ret, ".?");
if ((socklen_t)(((char*)&addr->sin_port)-(char*)addr+(int)sizeof(addr->sin_port)) < socklen) {
port = ntohs(addr->sin_port);
if (port)
rb_str_catf(ret, ":%d", port);
}
else {
rb_str_cat2(ret, ":?");
}
if ((socklen_t)sizeof(struct sockaddr_in) != socklen)
rb_str_catf(ret, " (%d bytes for %d bytes sockaddr_in)",
(int)socklen,
(int)sizeof(struct sockaddr_in));
break;
}
#ifdef AF_INET6
case AF_INET6:
{
struct sockaddr_in6 *addr;
char hbuf[1024];
int port;
int error;
if (socklen < (socklen_t)sizeof(struct sockaddr_in6)) {
rb_str_catf(ret, "too-short-AF_INET6-sockaddr %d bytes", (int)socklen);
}
else {
addr = &sockaddr->in6;
/* use getnameinfo for scope_id.
* RFC 4007: IPv6 Scoped Address Architecture
* draft-ietf-ipv6-scope-api-00.txt: Scoped Address Extensions to the IPv6 Basic Socket API
*/
error = getnameinfo(&sockaddr->addr, socklen,
hbuf, (socklen_t)sizeof(hbuf), NULL, 0,
NI_NUMERICHOST|NI_NUMERICSERV);
if (error) {
rsock_raise_socket_error("getnameinfo", error);
}
if (addr->sin6_port == 0) {
rb_str_cat2(ret, hbuf);
}
else {
port = ntohs(addr->sin6_port);
rb_str_catf(ret, "[%s]:%d", hbuf, port);
}
if ((socklen_t)sizeof(struct sockaddr_in6) < socklen)
rb_str_catf(ret, "(sockaddr %d bytes too long)", (int)(socklen - sizeof(struct sockaddr_in6)));
}
break;
}
#endif
#ifdef HAVE_SYS_UN_H
case AF_UNIX:
{
struct sockaddr_un *addr = &sockaddr->un;
char *p, *s, *e;
s = addr->sun_path;
e = (char*)addr + socklen;
while (s < e && *(e-1) == '\0')
e--;
if (e < s)
rb_str_cat2(ret, "too-short-AF_UNIX-sockaddr");
else if (s == e)
rb_str_cat2(ret, "empty-path-AF_UNIX-sockaddr");
else {
int printable_only = 1;
p = s;
while (p < e) {
printable_only = printable_only && ISPRINT(*p) && !ISSPACE(*p);
p++;
}
if (printable_only) { /* only printable, no space */
if (s[0] != '/') /* relative path */
rb_str_cat2(ret, "UNIX ");
rb_str_cat(ret, s, p - s);
}
else {
rb_str_cat2(ret, "UNIX");
while (s < e)
rb_str_catf(ret, ":%02x", (unsigned char)*s++);
}
}
break;
}
#endif
#if defined(AF_PACKET) && defined(__linux__)
/* GNU/Linux */
case AF_PACKET:
{
struct sockaddr_ll *addr;
const char *sep = "[";
#define CATSEP do { rb_str_cat2(ret, sep); sep = " "; } while (0);
addr = (struct sockaddr_ll *)sockaddr;
rb_str_cat2(ret, "PACKET");
if (offsetof(struct sockaddr_ll, sll_protocol) + sizeof(addr->sll_protocol) <= (size_t)socklen) {
CATSEP;
rb_str_catf(ret, "protocol=%d", ntohs(addr->sll_protocol));
}
if (offsetof(struct sockaddr_ll, sll_ifindex) + sizeof(addr->sll_ifindex) <= (size_t)socklen) {
char buf[IFNAMSIZ];
CATSEP;
if (if_indextoname(addr->sll_ifindex, buf) == NULL)
rb_str_catf(ret, "ifindex=%d", addr->sll_ifindex);
else
rb_str_catf(ret, "%s", buf);
}
if (offsetof(struct sockaddr_ll, sll_hatype) + sizeof(addr->sll_hatype) <= (size_t)socklen) {
CATSEP;
rb_str_catf(ret, "hatype=%d", addr->sll_hatype);
}
if (offsetof(struct sockaddr_ll, sll_pkttype) + sizeof(addr->sll_pkttype) <= (size_t)socklen) {
CATSEP;
if (addr->sll_pkttype == PACKET_HOST)
rb_str_cat2(ret, "HOST");
else if (addr->sll_pkttype == PACKET_BROADCAST)
rb_str_cat2(ret, "BROADCAST");
else if (addr->sll_pkttype == PACKET_MULTICAST)
rb_str_cat2(ret, "MULTICAST");
else if (addr->sll_pkttype == PACKET_OTHERHOST)
rb_str_cat2(ret, "OTHERHOST");
else if (addr->sll_pkttype == PACKET_OUTGOING)
rb_str_cat2(ret, "OUTGOING");
else
rb_str_catf(ret, "pkttype=%d", addr->sll_pkttype);
}
if (socklen != (socklen_t)(offsetof(struct sockaddr_ll, sll_addr) + addr->sll_halen)) {
CATSEP;
if (offsetof(struct sockaddr_ll, sll_halen) + sizeof(addr->sll_halen) <= (size_t)socklen) {
rb_str_catf(ret, "halen=%d", addr->sll_halen);
}
}
if (offsetof(struct sockaddr_ll, sll_addr) < (size_t)socklen) {
socklen_t len, i;
CATSEP;
rb_str_cat2(ret, "hwaddr");
len = addr->sll_halen;
if ((size_t)socklen < offsetof(struct sockaddr_ll, sll_addr) + len)
len = socklen - offsetof(struct sockaddr_ll, sll_addr);
for (i = 0; i < len; i++) {
rb_str_cat2(ret, i == 0 ? "=" : ":");
rb_str_catf(ret, "%02x", addr->sll_addr[i]);
}
}
if (socklen < (socklen_t)(offsetof(struct sockaddr_ll, sll_halen) + sizeof(addr->sll_halen)) ||
(socklen_t)(offsetof(struct sockaddr_ll, sll_addr) + addr->sll_halen) != socklen) {
CATSEP;
rb_str_catf(ret, "(%d bytes for %d bytes sockaddr_ll)",
(int)socklen, (int)sizeof(struct sockaddr_ll));
}
rb_str_cat2(ret, "]");
#undef CATSEP
break;
}
#endif
#if defined(AF_LINK) && defined(HAVE_TYPE_STRUCT_SOCKADDR_DL)
/* AF_LINK is defined in 4.4BSD derivations since Net2.
link_ntoa is also defined at Net2.
However Debian GNU/kFreeBSD defines AF_LINK but
don't have link_ntoa. */
case AF_LINK:
{
/*
* Simple implementation using link_ntoa():
* This doesn't work on Debian GNU/kFreeBSD 6.0.7 (squeeze).
* Also, the format is bit different.
*
* rb_str_catf(ret, "LINK %s", link_ntoa(&sockaddr->dl));
* break;
*/
struct sockaddr_dl *addr = &sockaddr->dl;
char *np = NULL, *ap = NULL, *endp;
int nlen = 0, alen = 0;
int i, off;
const char *sep = "[";
#define CATSEP do { rb_str_cat2(ret, sep); sep = " "; } while (0);
rb_str_cat2(ret, "LINK");
endp = ((char *)addr) + socklen;
if (offsetof(struct sockaddr_dl, sdl_data) < socklen) {
np = addr->sdl_data;
nlen = addr->sdl_nlen;
if (endp - np < nlen)
nlen = (int)(endp - np);
}
off = addr->sdl_nlen;
if (offsetof(struct sockaddr_dl, sdl_data) + off < socklen) {
ap = addr->sdl_data + off;
alen = addr->sdl_alen;
if (endp - ap < alen)
alen = (int)(endp - ap);
}
CATSEP;
if (np)
rb_str_catf(ret, "%.*s", nlen, np);
else
rb_str_cat2(ret, "?");
if (ap && 0 < alen) {
CATSEP;
for (i = 0; i < alen; i++)
rb_str_catf(ret, "%s%02x", i == 0 ? "" : ":", (unsigned char)ap[i]);
}
if (socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_nlen) + sizeof(addr->sdl_nlen)) ||
socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_alen) + sizeof(addr->sdl_alen)) ||
socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_slen) + sizeof(addr->sdl_slen)) ||
/* longer length is possible behavior because struct sockaddr_dl has "minimum work area, can be larger" as the last field.
* cf. Net2:/usr/src/sys/net/if_dl.h. */
socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_data) + addr->sdl_nlen + addr->sdl_alen + addr->sdl_slen)) {
CATSEP;
rb_str_catf(ret, "(%d bytes for %d bytes sockaddr_dl)",
(int)socklen, (int)sizeof(struct sockaddr_dl));
}
rb_str_cat2(ret, "]");
#undef CATSEP
break;
}
#endif
default:
{
ID id = rsock_intern_family(sockaddr->addr.sa_family);
if (id == 0)
rb_str_catf(ret, "unknown address family %d", sockaddr->addr.sa_family);
else
rb_str_catf(ret, "%s address format unknown", rb_id2name(id));
break;
}
}
}
return ret;
}
/*
* call-seq:
* addrinfo.inspect => string
*
* returns a string which shows addrinfo in human-readable form.
*
* Addrinfo.tcp("localhost", 80).inspect #=> "#<Addrinfo: 127.0.0.1:80 TCP (localhost)>"
* Addrinfo.unix("/tmp/sock").inspect #=> "#<Addrinfo: /tmp/sock SOCK_STREAM>"
*
*/
static VALUE
addrinfo_inspect(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int internet_p;
VALUE ret;
ret = rb_sprintf("#<%s: ", rb_obj_classname(self));
inspect_sockaddr(self, ret);
if (rai->pfamily && ai_get_afamily(rai) != rai->pfamily) {
ID id = rsock_intern_protocol_family(rai->pfamily);
if (id)
rb_str_catf(ret, " %s", rb_id2name(id));
else
rb_str_catf(ret, " PF_\?\?\?(%d)", rai->pfamily);
}
internet_p = rai->pfamily == PF_INET;
#ifdef INET6
internet_p = internet_p || rai->pfamily == PF_INET6;
#endif
if (internet_p && rai->socktype == SOCK_STREAM &&
(rai->protocol == 0 || rai->protocol == IPPROTO_TCP)) {
rb_str_cat2(ret, " TCP");
}
else if (internet_p && rai->socktype == SOCK_DGRAM &&
(rai->protocol == 0 || rai->protocol == IPPROTO_UDP)) {
rb_str_cat2(ret, " UDP");
}
else {
if (rai->socktype) {
ID id = rsock_intern_socktype(rai->socktype);
if (id)
rb_str_catf(ret, " %s", rb_id2name(id));
else
rb_str_catf(ret, " SOCK_\?\?\?(%d)", rai->socktype);
}
if (rai->protocol) {
if (internet_p) {
ID id = rsock_intern_ipproto(rai->protocol);
if (id)
rb_str_catf(ret, " %s", rb_id2name(id));
else
goto unknown_protocol;
}
else {
unknown_protocol:
rb_str_catf(ret, " UNKNOWN_PROTOCOL(%d)", rai->protocol);
}
}
}
if (!NIL_P(rai->canonname)) {
VALUE name = rai->canonname;
rb_str_catf(ret, " %s", StringValueCStr(name));
}
if (!NIL_P(rai->inspectname)) {
VALUE name = rai->inspectname;
rb_str_catf(ret, " (%s)", StringValueCStr(name));
}
rb_str_buf_cat2(ret, ">");
return ret;
}
/*
* call-seq:
* addrinfo.inspect_sockaddr => string
*
* returns a string which shows the sockaddr in _addrinfo_ with human-readable form.
*
* Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80"
* Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80"
* Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock"
*
*/
VALUE
rsock_addrinfo_inspect_sockaddr(VALUE self)
{
return inspect_sockaddr(self, rb_str_new("", 0));
}
/* :nodoc: */
static VALUE
addrinfo_mdump(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
VALUE sockaddr, afamily, pfamily, socktype, protocol, canonname, inspectname;
int afamily_int = ai_get_afamily(rai);
ID id;
id = rsock_intern_protocol_family(rai->pfamily);
if (id == 0)
rb_raise(rb_eSocket, "unknown protocol family: %d", rai->pfamily);
pfamily = rb_id2str(id);
if (rai->socktype == 0)
socktype = INT2FIX(0);
else {
id = rsock_intern_socktype(rai->socktype);
if (id == 0)
rb_raise(rb_eSocket, "unknown socktype: %d", rai->socktype);
socktype = rb_id2str(id);
}
if (rai->protocol == 0)
protocol = INT2FIX(0);
else if (IS_IP_FAMILY(afamily_int)) {
id = rsock_intern_ipproto(rai->protocol);
if (id == 0)
rb_raise(rb_eSocket, "unknown IP protocol: %d", rai->protocol);
protocol = rb_id2str(id);
}
else {
rb_raise(rb_eSocket, "unknown protocol: %d", rai->protocol);
}
canonname = rai->canonname;
inspectname = rai->inspectname;
id = rsock_intern_family(afamily_int);
if (id == 0)
rb_raise(rb_eSocket, "unknown address family: %d", afamily_int);
afamily = rb_id2str(id);
switch(afamily_int) {
#ifdef HAVE_SYS_UN_H
case AF_UNIX:
{
struct sockaddr_un *su = &rai->addr.un;
char *s, *e;
s = su->sun_path;
e = (char*)su + rai->sockaddr_len;
while (s < e && *(e-1) == '\0')
e--;
sockaddr = rb_str_new(s, e-s);
break;
}
#endif
default:
{
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
int error;
error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
NI_NUMERICHOST|NI_NUMERICSERV);
if (error) {
rsock_raise_socket_error("getnameinfo", error);
}
sockaddr = rb_assoc_new(rb_str_new_cstr(hbuf), rb_str_new_cstr(pbuf));
break;
}
}
return rb_ary_new3(7, afamily, sockaddr, pfamily, socktype, protocol, canonname, inspectname);
}
/* :nodoc: */
static VALUE
addrinfo_mload(VALUE self, VALUE ary)
{
VALUE v;
VALUE canonname, inspectname;
int afamily, pfamily, socktype, protocol;
union_sockaddr ss;
socklen_t len;
rb_addrinfo_t *rai;
if (check_addrinfo(self))
rb_raise(rb_eTypeError, "already initialized socket address");
ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
v = rb_ary_entry(ary, 0);
StringValue(v);
if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &afamily) == -1)
rb_raise(rb_eTypeError, "unexpected address family");
v = rb_ary_entry(ary, 2);
StringValue(v);
if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &pfamily) == -1)
rb_raise(rb_eTypeError, "unexpected protocol family");
v = rb_ary_entry(ary, 3);
if (v == INT2FIX(0))
socktype = 0;
else {
StringValue(v);
if (rsock_socktype_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &socktype) == -1)
rb_raise(rb_eTypeError, "unexpected socktype");
}
v = rb_ary_entry(ary, 4);
if (v == INT2FIX(0))
protocol = 0;
else {
StringValue(v);
if (IS_IP_FAMILY(afamily)) {
if (rsock_ipproto_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &protocol) == -1)
rb_raise(rb_eTypeError, "unexpected protocol");
}
else {
rb_raise(rb_eTypeError, "unexpected protocol");
}
}
v = rb_ary_entry(ary, 5);
if (NIL_P(v))
canonname = Qnil;
else {
StringValue(v);
canonname = v;
}
v = rb_ary_entry(ary, 6);
if (NIL_P(v))
inspectname = Qnil;
else {
StringValue(v);
inspectname = v;
}
v = rb_ary_entry(ary, 1);
switch(afamily) {
#ifdef HAVE_SYS_UN_H
case AF_UNIX:
{
struct sockaddr_un uaddr;
INIT_SOCKADDR_UN(&uaddr, sizeof(struct sockaddr_un));
StringValue(v);
if (sizeof(uaddr.sun_path) < (size_t)RSTRING_LEN(v))
rb_raise(rb_eSocket,
"too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
(size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path));
memcpy(uaddr.sun_path, RSTRING_PTR(v), RSTRING_LEN(v));
len = (socklen_t)sizeof(uaddr);
memcpy(&ss, &uaddr, len);
break;
}
#endif
default:
{
VALUE pair = rb_convert_type(v, T_ARRAY, "Array", "to_ary");
struct rb_addrinfo *res;
int flags = AI_NUMERICHOST;
#ifdef AI_NUMERICSERV
flags |= AI_NUMERICSERV;
#endif
res = call_getaddrinfo(rb_ary_entry(pair, 0), rb_ary_entry(pair, 1),
INT2NUM(pfamily), INT2NUM(socktype), INT2NUM(protocol),
INT2NUM(flags), 1);
len = res->ai->ai_addrlen;
memcpy(&ss, res->ai->ai_addr, res->ai->ai_addrlen);
rb_freeaddrinfo(res);
break;
}
}
DATA_PTR(self) = rai = alloc_addrinfo();
init_addrinfo(rai, &ss.addr, len,
pfamily, socktype, protocol,
canonname, inspectname);
return self;
}
/*
* call-seq:
* addrinfo.afamily => integer
*
* returns the address family as an integer.
*
* Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true
*
*/
static VALUE
addrinfo_afamily(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
return INT2NUM(ai_get_afamily(rai));
}
/*
* call-seq:
* addrinfo.pfamily => integer
*
* returns the protocol family as an integer.
*
* Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true
*
*/
static VALUE
addrinfo_pfamily(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
return INT2NUM(rai->pfamily);
}
/*
* call-seq:
* addrinfo.socktype => integer
*
* returns the socket type as an integer.
*
* Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true
*
*/
static VALUE
addrinfo_socktype(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
return INT2NUM(rai->socktype);
}
/*
* call-seq:
* addrinfo.protocol => integer
*
* returns the socket type as an integer.
*
* Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true
*
*/
static VALUE
addrinfo_protocol(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
return INT2NUM(rai->protocol);
}
/*
* call-seq:
* addrinfo.to_sockaddr => string
* addrinfo.to_s => string
*
* returns the socket address as packed struct sockaddr string.
*
* Addrinfo.tcp("localhost", 80).to_sockaddr
* #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
*
*/
static VALUE
addrinfo_to_sockaddr(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
VALUE ret;
ret = rb_str_new((char*)&rai->addr, rai->sockaddr_len);
OBJ_INFECT(ret, self);
return ret;
}
/*
* call-seq:
* addrinfo.canonname => string or nil
*
* returns the canonical name as an string.
*
* nil is returned if no canonical name.
*
* The canonical name is set by Addrinfo.getaddrinfo when AI_CANONNAME is specified.
*
* list = Addrinfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME)
* p list[0] #=> #<Addrinfo: 221.186.184.68:80 TCP carbon.ruby-lang.org (www.ruby-lang.org)>
* p list[0].canonname #=> "carbon.ruby-lang.org"
*
*/
static VALUE
addrinfo_canonname(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
return rai->canonname;
}
/*
* call-seq:
* addrinfo.ip? => true or false
*
* returns true if addrinfo is internet (IPv4/IPv6) address.
* returns false otherwise.
*
* Addrinfo.tcp("127.0.0.1", 80).ip? #=> true
* Addrinfo.tcp("::1", 80).ip? #=> true
* Addrinfo.unix("/tmp/sock").ip? #=> false
*
*/
static VALUE
addrinfo_ip_p(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
return IS_IP_FAMILY(family) ? Qtrue : Qfalse;
}
/*
* call-seq:
* addrinfo.ipv4? => true or false
*
* returns true if addrinfo is IPv4 address.
* returns false otherwise.
*
* Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true
* Addrinfo.tcp("::1", 80).ipv4? #=> false
* Addrinfo.unix("/tmp/sock").ipv4? #=> false
*
*/
static VALUE
addrinfo_ipv4_p(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
return ai_get_afamily(rai) == AF_INET ? Qtrue : Qfalse;
}
/*
* call-seq:
* addrinfo.ipv6? => true or false
*
* returns true if addrinfo is IPv6 address.
* returns false otherwise.
*
* Addrinfo.tcp("127.0.0.1", 80).ipv6? #=> false
* Addrinfo.tcp("::1", 80).ipv6? #=> true
* Addrinfo.unix("/tmp/sock").ipv6? #=> false
*
*/
static VALUE
addrinfo_ipv6_p(VALUE self)
{
#ifdef AF_INET6
rb_addrinfo_t *rai = get_addrinfo(self);
return ai_get_afamily(rai) == AF_INET6 ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
}
/*
* call-seq:
* addrinfo.unix? => true or false
*
* returns true if addrinfo is UNIX address.
* returns false otherwise.
*
* Addrinfo.tcp("127.0.0.1", 80).unix? #=> false
* Addrinfo.tcp("::1", 80).unix? #=> false
* Addrinfo.unix("/tmp/sock").unix? #=> true
*
*/
static VALUE
addrinfo_unix_p(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
#ifdef AF_UNIX
return ai_get_afamily(rai) == AF_UNIX ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
}
/*
* call-seq:
* addrinfo.getnameinfo => [nodename, service]
* addrinfo.getnameinfo(flags) => [nodename, service]
*
* returns nodename and service as a pair of strings.
* This converts struct sockaddr in addrinfo to textual representation.
*
* flags should be bitwise OR of Socket::NI_??? constants.
*
* Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"]
*
* Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV)
* #=> ["localhost", "80"]
*/
static VALUE
addrinfo_getnameinfo(int argc, VALUE *argv, VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
VALUE vflags;
char hbuf[1024], pbuf[1024];
int flags, error;
rb_scan_args(argc, argv, "01", &vflags);
flags = NIL_P(vflags) ? 0 : NUM2INT(vflags);
if (rai->socktype == SOCK_DGRAM)
flags |= NI_DGRAM;
error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
flags);
if (error) {
rsock_raise_socket_error("getnameinfo", error);
}
return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
}
/*
* call-seq:
* addrinfo.ip_unpack => [addr, port]
*
* Returns the IP address and port number as 2-element array.
*
* Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80]
* Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80]
*/
static VALUE
addrinfo_ip_unpack(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
VALUE vflags;
VALUE ret, portstr;
if (!IS_IP_FAMILY(family))
rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
vflags = INT2NUM(NI_NUMERICHOST|NI_NUMERICSERV);
ret = addrinfo_getnameinfo(1, &vflags, self);
portstr = rb_ary_entry(ret, 1);
rb_ary_store(ret, 1, INT2NUM(atoi(StringValueCStr(portstr))));
return ret;
}
/*
* call-seq:
* addrinfo.ip_address => string
*
* Returns the IP address as a string.
*
* Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1"
* Addrinfo.tcp("::1", 80).ip_address #=> "::1"
*/
static VALUE
addrinfo_ip_address(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
VALUE vflags;
VALUE ret;
if (!IS_IP_FAMILY(family))
rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
vflags = INT2NUM(NI_NUMERICHOST|NI_NUMERICSERV);
ret = addrinfo_getnameinfo(1, &vflags, self);
return rb_ary_entry(ret, 0);
}
/*
* call-seq:
* addrinfo.ip_port => port
*
* Returns the port number as an integer.
*
* Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80
* Addrinfo.tcp("::1", 80).ip_port #=> 80
*/
static VALUE
addrinfo_ip_port(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
int port;
if (!IS_IP_FAMILY(family)) {
bad_family:
#ifdef AF_INET6
rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
#else
rb_raise(rb_eSocket, "need IPv4 address");
#endif
}
switch (family) {
case AF_INET:
if (rai->sockaddr_len != sizeof(struct sockaddr_in))
rb_raise(rb_eSocket, "unexpected sockaddr size for IPv4");
port = ntohs(rai->addr.in.sin_port);
break;
#ifdef AF_INET6
case AF_INET6:
if (rai->sockaddr_len != sizeof(struct sockaddr_in6))
rb_raise(rb_eSocket, "unexpected sockaddr size for IPv6");
port = ntohs(rai->addr.in6.sin6_port);
break;
#endif
default:
goto bad_family;
}
return INT2NUM(port);
}
static int
extract_in_addr(VALUE self, uint32_t *addrp)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
if (family != AF_INET) return 0;
*addrp = ntohl(rai->addr.in.sin_addr.s_addr);
return 1;
}
/*
* Returns true for IPv4 private address (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv4_private_p(VALUE self)
{
uint32_t a;
if (!extract_in_addr(self, &a)) return Qfalse;
if ((a & 0xff000000) == 0x0a000000 || /* 10.0.0.0/8 */
(a & 0xfff00000) == 0xac100000 || /* 172.16.0.0/12 */
(a & 0xffff0000) == 0xc0a80000) /* 192.168.0.0/16 */
return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv4 loopback address (127.0.0.0/8).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv4_loopback_p(VALUE self)
{
uint32_t a;
if (!extract_in_addr(self, &a)) return Qfalse;
if ((a & 0xff000000) == 0x7f000000) /* 127.0.0.0/8 */
return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv4 multicast address (224.0.0.0/4).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv4_multicast_p(VALUE self)
{
uint32_t a;
if (!extract_in_addr(self, &a)) return Qfalse;
if ((a & 0xf0000000) == 0xe0000000) /* 224.0.0.0/4 */
return Qtrue;
return Qfalse;
}
#ifdef INET6
static struct in6_addr *
extract_in6_addr(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
if (family != AF_INET6) return NULL;
return &rai->addr.in6.sin6_addr;
}
/*
* Returns true for IPv6 unspecified address (::).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_unspecified_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_UNSPECIFIED(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 loopback address (::1).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_loopback_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_LOOPBACK(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 multicast address (ff00::/8).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_multicast_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_MULTICAST(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 link local address (ff80::/10).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_linklocal_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_LINKLOCAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 site local address (ffc0::/10).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_sitelocal_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_SITELOCAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 unique local address (fc00::/7, RFC4193).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_unique_local_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_UNIQUE_LOCAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_v4mapped_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_V4MAPPED(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv4-compatible IPv6 address (::/80).
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_v4compat_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_V4COMPAT(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 multicast node-local scope address.
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_mc_nodelocal_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_MC_NODELOCAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 multicast link-local scope address.
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_mc_linklocal_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_MC_LINKLOCAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 multicast site-local scope address.
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_mc_sitelocal_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_MC_SITELOCAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 multicast organization-local scope address.
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_mc_orglocal_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_MC_ORGLOCAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns true for IPv6 multicast global scope address.
* It returns false otherwise.
*/
static VALUE
addrinfo_ipv6_mc_global_p(VALUE self)
{
struct in6_addr *addr = extract_in6_addr(self);
if (addr && IN6_IS_ADDR_MC_GLOBAL(addr)) return Qtrue;
return Qfalse;
}
/*
* Returns IPv4 address of IPv4 mapped/compatible IPv6 address.
* It returns nil if +self+ is not IPv4 mapped/compatible IPv6 address.
*
* Addrinfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
* Addrinfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
* Addrinfo.ip("::1").ipv6_to_ipv4 #=> nil
* Addrinfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil
* Addrinfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil
*/
static VALUE
addrinfo_ipv6_to_ipv4(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
struct in6_addr *addr;
int family = ai_get_afamily(rai);
if (family != AF_INET6) return Qnil;
addr = &rai->addr.in6.sin6_addr;
if (IN6_IS_ADDR_V4MAPPED(addr) || IN6_IS_ADDR_V4COMPAT(addr)) {
struct sockaddr_in sin4;
INIT_SOCKADDR_IN(&sin4, sizeof(sin4));
memcpy(&sin4.sin_addr, (char*)addr + sizeof(*addr) - sizeof(sin4.sin_addr), sizeof(sin4.sin_addr));
return rsock_addrinfo_new((struct sockaddr *)&sin4, (socklen_t)sizeof(sin4),
PF_INET, rai->socktype, rai->protocol,
rai->canonname, rai->inspectname);
}
else {
return Qnil;
}
}
#endif
#ifdef HAVE_SYS_UN_H
/*
* call-seq:
* addrinfo.unix_path => path
*
* Returns the socket path as a string.
*
* Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock"
*/
static VALUE
addrinfo_unix_path(VALUE self)
{
rb_addrinfo_t *rai = get_addrinfo(self);
int family = ai_get_afamily(rai);
struct sockaddr_un *addr;
char *s, *e;
if (family != AF_UNIX)
rb_raise(rb_eSocket, "need AF_UNIX address");
addr = &rai->addr.un;
s = addr->sun_path;
e = (char*)addr + rai->sockaddr_len;
if (e < s)
rb_raise(rb_eSocket, "too short AF_UNIX address: %"PRIuSIZE" bytes given for minimum %"PRIuSIZE" bytes.",
(size_t)rai->sockaddr_len, (size_t)(s - (char *)addr));
if (addr->sun_path + sizeof(addr->sun_path) < e)
rb_raise(rb_eSocket,
"too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
(size_t)(e - addr->sun_path), sizeof(addr->sun_path));
while (s < e && *(e-1) == '\0')
e--;
return rb_str_new(s, e-s);
}
#endif
/*
* call-seq:
* Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags) => [addrinfo, ...]
* Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol) => [addrinfo, ...]
* Addrinfo.getaddrinfo(nodename, service, family, socktype) => [addrinfo, ...]
* Addrinfo.getaddrinfo(nodename, service, family) => [addrinfo, ...]
* Addrinfo.getaddrinfo(nodename, service) => [addrinfo, ...]
*
* returns a list of addrinfo objects as an array.
*
* This method converts nodename (hostname) and service (port) to addrinfo.
* Since the conversion is not unique, the result is a list of addrinfo objects.
*
* nodename or service can be nil if no conversion intended.
*
* family, socktype and protocol are hint for preferred protocol.
* If the result will be used for a socket with SOCK_STREAM,
* SOCK_STREAM should be specified as socktype.
* If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM.
* If they are omitted or nil is given, the result is not restricted.
*
* Similarly, PF_INET6 as family restricts for IPv6.
*
* flags should be bitwise OR of Socket::AI_??? constants such as follows.
* Note that the exact list of the constants depends on OS.
*
* AI_PASSIVE Get address to use with bind()
* AI_CANONNAME Fill in the canonical name
* AI_NUMERICHOST Prevent host name resolution
* AI_NUMERICSERV Prevent service name resolution
* AI_V4MAPPED Accept IPv4-mapped IPv6 addresses
* AI_ALL Allow all addresses
* AI_ADDRCONFIG Accept only if any address is assigned
*
* Note that socktype should be specified whenever application knows the usage of the address.
* Some platform causes an error when socktype is omitted and servname is specified as an integer
* because some port numbers, 512 for example, are ambiguous without socktype.
*
* Addrinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM)
* #=> [#<Addrinfo: 203.178.141.194:80 TCP (www.kame.net)>,
* # #<Addrinfo: [2001:200:dff:fff1:216:3eff:feb1:44d7]:80 TCP (www.kame.net)>]
*
*/
static VALUE
addrinfo_s_getaddrinfo(int argc, VALUE *argv, VALUE self)
{
VALUE node, service, family, socktype, protocol, flags;
rb_scan_args(argc, argv, "24", &node, &service, &family, &socktype, &protocol, &flags);
return addrinfo_list_new(node, service, family, socktype, protocol, flags);
}
/*
* call-seq:
* Addrinfo.ip(host) => addrinfo
*
* returns an addrinfo object for IP address.
*
* The port, socktype, protocol of the result is filled by zero.
* So, it is not appropriate to create a socket.
*
* Addrinfo.ip("localhost") #=> #<Addrinfo: 127.0.0.1 (localhost)>
*/
static VALUE
addrinfo_s_ip(VALUE self, VALUE host)
{
VALUE ret;
rb_addrinfo_t *rai;
ret = addrinfo_firstonly_new(host, Qnil,
INT2NUM(PF_UNSPEC), INT2FIX(0), INT2FIX(0), INT2FIX(0));
rai = get_addrinfo(ret);
rai->socktype = 0;
rai->protocol = 0;
return ret;
}
/*
* call-seq:
* Addrinfo.tcp(host, port) => addrinfo
*
* returns an addrinfo object for TCP address.
*
* Addrinfo.tcp("localhost", "smtp") #=> #<Addrinfo: 127.0.0.1:25 TCP (localhost:smtp)>
*/
static VALUE
addrinfo_s_tcp(VALUE self, VALUE host, VALUE port)
{
return addrinfo_firstonly_new(host, port,
INT2NUM(PF_UNSPEC), INT2NUM(SOCK_STREAM), INT2NUM(IPPROTO_TCP), INT2FIX(0));
}
/*
* call-seq:
* Addrinfo.udp(host, port) => addrinfo
*
* returns an addrinfo object for UDP address.
*
* Addrinfo.udp("localhost", "daytime") #=> #<Addrinfo: 127.0.0.1:13 UDP (localhost:daytime)>
*/
static VALUE
addrinfo_s_udp(VALUE self, VALUE host, VALUE port)
{
return addrinfo_firstonly_new(host, port,
INT2NUM(PF_UNSPEC), INT2NUM(SOCK_DGRAM), INT2NUM(IPPROTO_UDP), INT2FIX(0));
}
#ifdef HAVE_SYS_UN_H
/*
* call-seq:
* Addrinfo.unix(path [, socktype]) => addrinfo
*
* returns an addrinfo object for UNIX socket address.
*
* _socktype_ specifies the socket type.
* If it is omitted, :STREAM is used.
*
* Addrinfo.unix("/tmp/sock") #=> #<Addrinfo: /tmp/sock SOCK_STREAM>
* Addrinfo.unix("/tmp/sock", :DGRAM) #=> #<Addrinfo: /tmp/sock SOCK_DGRAM>
*/
static VALUE
addrinfo_s_unix(int argc, VALUE *argv, VALUE self)
{
VALUE path, vsocktype, addr;
int socktype;
rb_addrinfo_t *rai;
rb_scan_args(argc, argv, "11", &path, &vsocktype);
if (NIL_P(vsocktype))
socktype = SOCK_STREAM;
else
socktype = rsock_socktype_arg(vsocktype);
addr = addrinfo_s_allocate(rb_cAddrinfo);
DATA_PTR(addr) = rai = alloc_addrinfo();
init_unix_addrinfo(rai, path, socktype);
OBJ_INFECT(addr, path);
return addr;
}
#endif
VALUE
rsock_sockaddr_string_value(volatile VALUE *v)
{
VALUE val = *v;
if (IS_ADDRINFO(val)) {
*v = addrinfo_to_sockaddr(val);
}
StringValue(*v);
return *v;
}
VALUE
rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *rai_ret)
{
VALUE val = *v;
*rai_ret = Qnil;
if (IS_ADDRINFO(val)) {
*v = addrinfo_to_sockaddr(val);
*rai_ret = val;
}
StringValue(*v);
return *v;
}
char *
rsock_sockaddr_string_value_ptr(volatile VALUE *v)
{
rsock_sockaddr_string_value(v);
return RSTRING_PTR(*v);
}
VALUE
rb_check_sockaddr_string_type(VALUE val)
{
if (IS_ADDRINFO(val))
return addrinfo_to_sockaddr(val);
return rb_check_string_type(val);
}
VALUE
rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
{
int family;
int socktype;
int ret;
socklen_t optlen = (socklen_t)sizeof(socktype);
/* assumes protocol family and address family are identical */
family = get_afamily(addr, len);
ret = getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&socktype, &optlen);
if (ret == -1) {
rb_sys_fail("getsockopt(SO_TYPE)");
}
return rsock_addrinfo_new(addr, len, family, socktype, 0, Qnil, Qnil);
}
VALUE
rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
{
rb_io_t *fptr;
switch (TYPE(io)) {
case T_FIXNUM:
return rsock_fd_socket_addrinfo(FIX2INT(io), addr, len);
case T_BIGNUM:
return rsock_fd_socket_addrinfo(NUM2INT(io), addr, len);
case T_FILE:
GetOpenFile(io, fptr);
return rsock_fd_socket_addrinfo(fptr->fd, addr, len);
default:
rb_raise(rb_eTypeError, "neither IO nor file descriptor");
}
UNREACHABLE;
}
/*
* Addrinfo class
*/
void
rsock_init_addrinfo(void)
{
/*
* The Addrinfo class maps <tt>struct addrinfo</tt> to ruby. This
* structure identifies an Internet host and a service.
*/
rb_cAddrinfo = rb_define_class("Addrinfo", rb_cData);
rb_define_alloc_func(rb_cAddrinfo, addrinfo_s_allocate);
rb_define_method(rb_cAddrinfo, "initialize", addrinfo_initialize, -1);
rb_define_method(rb_cAddrinfo, "inspect", addrinfo_inspect, 0);
rb_define_method(rb_cAddrinfo, "inspect_sockaddr", rsock_addrinfo_inspect_sockaddr, 0);
rb_define_singleton_method(rb_cAddrinfo, "getaddrinfo", addrinfo_s_getaddrinfo, -1);
rb_define_singleton_method(rb_cAddrinfo, "ip", addrinfo_s_ip, 1);
rb_define_singleton_method(rb_cAddrinfo, "tcp", addrinfo_s_tcp, 2);
rb_define_singleton_method(rb_cAddrinfo, "udp", addrinfo_s_udp, 2);
#ifdef HAVE_SYS_UN_H
rb_define_singleton_method(rb_cAddrinfo, "unix", addrinfo_s_unix, -1);
#endif
rb_define_method(rb_cAddrinfo, "afamily", addrinfo_afamily, 0);
rb_define_method(rb_cAddrinfo, "pfamily", addrinfo_pfamily, 0);
rb_define_method(rb_cAddrinfo, "socktype", addrinfo_socktype, 0);
rb_define_method(rb_cAddrinfo, "protocol", addrinfo_protocol, 0);
rb_define_method(rb_cAddrinfo, "canonname", addrinfo_canonname, 0);
rb_define_method(rb_cAddrinfo, "ipv4?", addrinfo_ipv4_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6?", addrinfo_ipv6_p, 0);
rb_define_method(rb_cAddrinfo, "unix?", addrinfo_unix_p, 0);
rb_define_method(rb_cAddrinfo, "ip?", addrinfo_ip_p, 0);
rb_define_method(rb_cAddrinfo, "ip_unpack", addrinfo_ip_unpack, 0);
rb_define_method(rb_cAddrinfo, "ip_address", addrinfo_ip_address, 0);
rb_define_method(rb_cAddrinfo, "ip_port", addrinfo_ip_port, 0);
rb_define_method(rb_cAddrinfo, "ipv4_private?", addrinfo_ipv4_private_p, 0);
rb_define_method(rb_cAddrinfo, "ipv4_loopback?", addrinfo_ipv4_loopback_p, 0);
rb_define_method(rb_cAddrinfo, "ipv4_multicast?", addrinfo_ipv4_multicast_p, 0);
#ifdef INET6
rb_define_method(rb_cAddrinfo, "ipv6_unspecified?", addrinfo_ipv6_unspecified_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_loopback?", addrinfo_ipv6_loopback_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_multicast?", addrinfo_ipv6_multicast_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_linklocal?", addrinfo_ipv6_linklocal_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_sitelocal?", addrinfo_ipv6_sitelocal_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_unique_local?", addrinfo_ipv6_unique_local_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_v4mapped?", addrinfo_ipv6_v4mapped_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_v4compat?", addrinfo_ipv6_v4compat_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_mc_nodelocal?", addrinfo_ipv6_mc_nodelocal_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_mc_linklocal?", addrinfo_ipv6_mc_linklocal_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_mc_sitelocal?", addrinfo_ipv6_mc_sitelocal_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_mc_orglocal?", addrinfo_ipv6_mc_orglocal_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_mc_global?", addrinfo_ipv6_mc_global_p, 0);
rb_define_method(rb_cAddrinfo, "ipv6_to_ipv4", addrinfo_ipv6_to_ipv4, 0);
#endif
#ifdef HAVE_SYS_UN_H
rb_define_method(rb_cAddrinfo, "unix_path", addrinfo_unix_path, 0);
#endif
rb_define_method(rb_cAddrinfo, "to_sockaddr", addrinfo_to_sockaddr, 0);
rb_define_method(rb_cAddrinfo, "to_s", addrinfo_to_sockaddr, 0); /* compatibility for ruby before 1.9.2 */
rb_define_method(rb_cAddrinfo, "getnameinfo", addrinfo_getnameinfo, -1);
rb_define_method(rb_cAddrinfo, "marshal_dump", addrinfo_mdump, 0);
rb_define_method(rb_cAddrinfo, "marshal_load", addrinfo_mload, 1);
}
| [
"aepifanov@tau-technologies.com"
] | aepifanov@tau-technologies.com |
8a5f2b36bff323adcf7a7ccfab009c4d5660bb15 | 8652a66d3994098ef4cf9186cd36171eb3833ad3 | /WINCE700/platform/common/src/soc/COMMON_TI_V1/COMMON_TI/INC/oal_i2c.h | c3504830eb3cee9dd1637f03ea47ddf97a41930c | [] | no_license | KunYi/em-works | 789e038ecaf4d0ec264d16fdd47df00b841de60c | 3b70b2690782acfcba7f4b0e43e05b5b070ed0da | refs/heads/master | 2016-09-06T03:47:56.913454 | 2013-11-05T03:28:15 | 2013-11-05T03:28:15 | 32,260,142 | 1 | 0 | null | null | null | null | UTF-8 | C | false | false | 3,134 | h | // All rights reserved ADENEO EMBEDDED 2010
/*
===============================================================================
* Texas Instruments OMAP(TM) Platform Software
* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
*
* Use of this software is controlled by the terms and conditions found
* in the license agreement under which this software has been supplied.
*
===============================================================================
*/
//
// File: oal_i2c.h
//
#ifndef __OAL_I2C_H
#define __OAL_I2C_H
#include "omap_types.h"
#include "omap_i2c_regs.h"
#ifdef __cplusplus
extern "C" {
#endif
//-----------------------------------------------------------------------------
// i2c scale table, used to look-up settings of baudIndex
//
typedef struct {
UINT16 psc;
UINT16 scll;
UINT16 sclh;
} I2CScaleTable_t;
//------------------------------------------------------------------------------
// i2c return value for i2c transactions
//
typedef enum {
kI2CSuccess,
kI2CFail,
kI2CRetry
} I2CResult_e;
//-----------------------------------------------------------------------------
// i2c context
//
typedef struct {
DWORD idI2C;
OMAP_DEVICE device;
DWORD baudIndex;
DWORD timeOut;
DWORD slaveAddress;
DWORD subAddressMode;
} I2CContext_t;
//------------------------------------------------------------------------------
// structures used for i2c transactions
//
typedef enum
{
kI2C_Read,
kI2C_Write
}
I2C_OPERATION_TYPE_e;
typedef struct
{
UINT size;
UCHAR *pBuffer;
}
I2C_BUFFER_INFO_t;
typedef struct __I2C_PACKET_INFO_t
{
UINT count; // number of elements in array
I2C_OPERATION_TYPE_e opType; // operation type (read/write)
UINT result; // number of bytes written/recieved
I2C_BUFFER_INFO_t *rgBuffers; // reference to buffers
}
I2C_PACKET_INFO_t;
typedef struct
{
UINT count;
UINT con_mask;
I2C_PACKET_INFO_t *rgPackets;
}
I2C_TRANSACTION_INFO_t;
//-----------------------------------------------------------------------------
// i2c device
//
typedef struct {
OMAP_DEVICE device;
DWORD ownAddress;
DWORD defaultBaudIndex;
DWORD maxRetries;
DWORD rxFifoThreshold;
DWORD txFifoThreshold;
OMAP_I2C_REGS *pI2CRegs;
DWORD currentBaudIndex;
DWORD fifoSize;
CRITICAL_SECTION cs;
} I2CDevice_t;
BOOL
OALI2CInit(
UINT devId
);
BOOL
OALI2CPostInit();
//------------------------------------------------------------------------------
#ifdef __cplusplus
}
#endif
#endif
| [
"lqk.sch@gmail.com@9677f95b-f147-b01e-6ec8-0db75aaa1bab"
] | lqk.sch@gmail.com@9677f95b-f147-b01e-6ec8-0db75aaa1bab |
4e4f3ffd592d184d22988b3ed7cc45d04763972f | b8e51e3433356f78f43c18a6ec5655dce5d48330 | /Labs/Saif/Test/color.h | c6b31320a25413a0c48b6a027348146d3a76addd | [] | no_license | SaifHaiderMalik/OOP | ac1a5b009f28213a10bd773ae5176f9fc3835063 | 28603eab6a3cd6bd328ed5ec3e0e2471fc1d6203 | refs/heads/master | 2022-10-24T08:53:13.235420 | 2020-06-08T22:18:34 | 2020-06-08T22:18:34 | 236,754,724 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 177 | h | void SetColorAndBackground(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
| [
"msaifhmalik@gmail.com"
] | msaifhmalik@gmail.com |
a9ef24b63fdf0a920426a6c320be1d879d426b82 | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /ndk/sources/host-tools/sed-4.2.1/lib/set-mode-acl.c | a24b9f348cc70bc1db0f9f85e215104db4e4d018 | [
"GPL-3.0-or-later",
"MIT",
"GFDL-1.3-only",
"GPL-3.0-only",
"LGPL-2.0-or-later"
] | 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 | 13,602 | c | /* set-mode-acl.c - set access control list equivalent to a mode
Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
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 3 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/>.
Written by Paul Eggert and Andreas Gruenbacher, and Bruno Haible. */
#include <config.h>
#include "acl.h"
#include "acl-internal.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
/* If DESC is a valid file descriptor use fchmod to change the
file's mode to MODE on systems that have fchown. On systems
that don't have fchown and if DESC is invalid, use chown on
NAME instead.
Return 0 if successful. Return -1 and set errno upon failure. */
int
chmod_or_fchmod (const char *name, int desc, mode_t mode)
{
if (HAVE_FCHMOD && desc != -1)
return fchmod (desc, mode);
else
return chmod (name, mode);
}
/* Set the access control lists of a file. If DESC is a valid file
descriptor, use file descriptor operations where available, else use
filename based operations on NAME. If access control lists are not
available, fchmod the target file to MODE. Also sets the
non-permission bits of the destination file (S_ISUID, S_ISGID, S_ISVTX)
to those from MODE if any are set.
Return 0 if successful. Return -1 and set errno upon failure. */
int
qset_acl (char const *name, int desc, mode_t mode)
{
#if USE_ACL
# if HAVE_ACL_GET_FILE
/* POSIX 1003.1e draft 17 (abandoned) specific version. */
/* Linux, FreeBSD, MacOS X, IRIX, Tru64 */
# if MODE_INSIDE_ACL
/* Linux, FreeBSD, IRIX, Tru64 */
/* We must also have acl_from_text and acl_delete_def_file.
(acl_delete_def_file could be emulated with acl_init followed
by acl_set_file, but acl_set_file with an empty acl is
unspecified.) */
# ifndef HAVE_ACL_FROM_TEXT
# error Must have acl_from_text (see POSIX 1003.1e draft 17).
# endif
# ifndef HAVE_ACL_DELETE_DEF_FILE
# error Must have acl_delete_def_file (see POSIX 1003.1e draft 17).
# endif
acl_t acl;
int ret;
if (HAVE_ACL_FROM_MODE) /* Linux */
{
acl = acl_from_mode (mode);
if (!acl)
return -1;
}
else /* FreeBSD, IRIX, Tru64 */
{
/* If we were to create the ACL using the functions acl_init(),
acl_create_entry(), acl_set_tag_type(), acl_set_qualifier(),
acl_get_permset(), acl_clear_perm[s](), acl_add_perm(), we
would need to create a qualifier. I don't know how to do this.
So create it using acl_from_text(). */
# if HAVE_ACL_FREE_TEXT /* Tru64 */
char acl_text[] = "u::---,g::---,o::---,";
# else /* FreeBSD, IRIX */
char acl_text[] = "u::---,g::---,o::---";
# endif
if (mode & S_IRUSR) acl_text[ 3] = 'r';
if (mode & S_IWUSR) acl_text[ 4] = 'w';
if (mode & S_IXUSR) acl_text[ 5] = 'x';
if (mode & S_IRGRP) acl_text[10] = 'r';
if (mode & S_IWGRP) acl_text[11] = 'w';
if (mode & S_IXGRP) acl_text[12] = 'x';
if (mode & S_IROTH) acl_text[17] = 'r';
if (mode & S_IWOTH) acl_text[18] = 'w';
if (mode & S_IXOTH) acl_text[19] = 'x';
acl = acl_from_text (acl_text);
if (!acl)
return -1;
}
if (HAVE_ACL_SET_FD && desc != -1)
ret = acl_set_fd (desc, acl);
else
ret = acl_set_file (name, ACL_TYPE_ACCESS, acl);
if (ret != 0)
{
int saved_errno = errno;
acl_free (acl);
if (ACL_NOT_WELL_SUPPORTED (errno))
return chmod_or_fchmod (name, desc, mode);
else
{
errno = saved_errno;
return -1;
}
}
else
acl_free (acl);
if (S_ISDIR (mode) && acl_delete_def_file (name))
return -1;
if (mode & (S_ISUID | S_ISGID | S_ISVTX))
{
/* We did not call chmod so far, so the special bits have not yet
been set. */
return chmod_or_fchmod (name, desc, mode);
}
return 0;
# else /* !MODE_INSIDE_ACL */
/* MacOS X */
# if !HAVE_ACL_TYPE_EXTENDED
# error Must have ACL_TYPE_EXTENDED
# endif
/* On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS)
and acl_get_file (name, ACL_TYPE_DEFAULT)
always return NULL / EINVAL. You have to use
acl_get_file (name, ACL_TYPE_EXTENDED)
or acl_get_fd (open (name, ...))
to retrieve an ACL.
On the other hand,
acl_set_file (name, ACL_TYPE_ACCESS, acl)
and acl_set_file (name, ACL_TYPE_DEFAULT, acl)
have the same effect as
acl_set_file (name, ACL_TYPE_EXTENDED, acl):
Each of these calls sets the file's ACL. */
acl_t acl;
int ret;
/* Remove the ACL if the file has ACLs. */
if (HAVE_ACL_GET_FD && desc != -1)
acl = acl_get_fd (desc);
else
acl = acl_get_file (name, ACL_TYPE_EXTENDED);
if (acl)
{
acl_free (acl);
acl = acl_init (0);
if (acl)
{
if (HAVE_ACL_SET_FD && desc != -1)
ret = acl_set_fd (desc, acl);
else
ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl);
if (ret != 0)
{
int saved_errno = errno;
acl_free (acl);
if (ACL_NOT_WELL_SUPPORTED (saved_errno))
return chmod_or_fchmod (name, desc, mode);
else
{
errno = saved_errno;
return -1;
}
}
acl_free (acl);
}
}
/* Since !MODE_INSIDE_ACL, we have to call chmod explicitly. */
return chmod_or_fchmod (name, desc, mode);
# endif
# elif HAVE_ACL && defined GETACLCNT /* Solaris, Cygwin, not HP-UX */
# if defined ACL_NO_TRIVIAL
/* Solaris 10 (newer version), which has additional API declared in
<sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial,
acl_fromtext, ...). */
acl_t *aclp;
char acl_text[] = "user::---,group::---,mask:---,other:---";
int ret;
int saved_errno;
if (mode & S_IRUSR) acl_text[ 6] = 'r';
if (mode & S_IWUSR) acl_text[ 7] = 'w';
if (mode & S_IXUSR) acl_text[ 8] = 'x';
if (mode & S_IRGRP) acl_text[17] = acl_text[26] = 'r';
if (mode & S_IWGRP) acl_text[18] = acl_text[27] = 'w';
if (mode & S_IXGRP) acl_text[19] = acl_text[28] = 'x';
if (mode & S_IROTH) acl_text[36] = 'r';
if (mode & S_IWOTH) acl_text[37] = 'w';
if (mode & S_IXOTH) acl_text[38] = 'x';
if (acl_fromtext (acl_text, &aclp) != 0)
{
errno = ENOMEM;
return -1;
}
ret = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp));
saved_errno = errno;
acl_free (aclp);
if (ret < 0)
{
if (saved_errno == ENOSYS)
return chmod_or_fchmod (name, desc, mode);
errno = saved_errno;
return -1;
}
if (mode & (S_ISUID | S_ISGID | S_ISVTX))
{
/* We did not call chmod so far, so the special bits have not yet
been set. */
return chmod_or_fchmod (name, desc, mode);
}
return 0;
# else /* Solaris, Cygwin, general case */
# ifdef ACE_GETACL
/* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
file systems (whereas the other ones are used in UFS file systems). */
/* The flags in the ace_t structure changed in a binary incompatible way
when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15.
How to distinguish the two conventions at runtime?
We fetch the existing ACL. In the old convention, usually three ACEs have
a_flags = ACE_OWNER / ACE_GROUP / ACE_OTHER, in the range 0x0100..0x0400.
In the new convention, these values are not used. */
int convention;
{
int count;
ace_t *entries;
for (;;)
{
if (desc != -1)
count = facl (desc, ACE_GETACLCNT, 0, NULL);
else
count = acl (name, ACE_GETACLCNT, 0, NULL);
if (count <= 0)
{
convention = -1;
break;
}
entries = (ace_t *) malloc (count * sizeof (ace_t));
if (entries == NULL)
{
errno = ENOMEM;
return -1;
}
if ((desc != -1
? facl (desc, ACE_GETACL, count, entries)
: acl (name, ACE_GETACL, count, entries))
== count)
{
int i;
convention = 0;
for (i = 0; i < count; i++)
if (entries[i].a_flags & (ACE_OWNER | ACE_GROUP | ACE_OTHER))
{
convention = 1;
break;
}
free (entries);
break;
}
/* Huh? The number of ACL entries changed since the last call.
Repeat. */
free (entries);
}
}
if (convention >= 0)
{
ace_t entries[3];
int ret;
if (convention)
{
/* Running on Solaris 10. */
entries[0].a_type = ALLOW;
entries[0].a_flags = ACE_OWNER;
entries[0].a_who = 0; /* irrelevant */
entries[0].a_access_mask = (mode >> 6) & 7;
entries[1].a_type = ALLOW;
entries[1].a_flags = ACE_GROUP;
entries[1].a_who = 0; /* irrelevant */
entries[1].a_access_mask = (mode >> 3) & 7;
entries[2].a_type = ALLOW;
entries[2].a_flags = ACE_OTHER;
entries[2].a_who = 0;
entries[2].a_access_mask = mode & 7;
}
else
{
/* Running on Solaris 10 (newer version) or Solaris 11. */
entries[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
entries[0].a_flags = NEW_ACE_OWNER;
entries[0].a_who = 0; /* irrelevant */
entries[0].a_access_mask =
(mode & 0400 ? NEW_ACE_READ_DATA : 0)
| (mode & 0200 ? NEW_ACE_WRITE_DATA : 0)
| (mode & 0100 ? NEW_ACE_EXECUTE : 0);
entries[1].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
entries[1].a_flags = NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP;
entries[1].a_who = 0; /* irrelevant */
entries[1].a_access_mask =
(mode & 0040 ? NEW_ACE_READ_DATA : 0)
| (mode & 0020 ? NEW_ACE_WRITE_DATA : 0)
| (mode & 0010 ? NEW_ACE_EXECUTE : 0);
entries[2].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
entries[2].a_flags = ACE_EVERYONE;
entries[2].a_who = 0;
entries[2].a_access_mask =
(mode & 0004 ? NEW_ACE_READ_DATA : 0)
| (mode & 0002 ? NEW_ACE_WRITE_DATA : 0)
| (mode & 0001 ? NEW_ACE_EXECUTE : 0);
}
if (desc != -1)
ret = facl (desc, ACE_SETACL,
sizeof (entries) / sizeof (ace_t), entries);
else
ret = acl (name, ACE_SETACL,
sizeof (entries) / sizeof (ace_t), entries);
if (ret < 0 && errno != EINVAL && errno != ENOTSUP)
{
if (errno == ENOSYS)
return chmod_or_fchmod (name, desc, mode);
return -1;
}
}
# endif
{
aclent_t entries[3];
int ret;
entries[0].a_type = USER_OBJ;
entries[0].a_id = 0; /* irrelevant */
entries[0].a_perm = (mode >> 6) & 7;
entries[1].a_type = GROUP_OBJ;
entries[1].a_id = 0; /* irrelevant */
entries[1].a_perm = (mode >> 3) & 7;
entries[2].a_type = OTHER_OBJ;
entries[2].a_id = 0;
entries[2].a_perm = mode & 7;
if (desc != -1)
ret = facl (desc, SETACL, sizeof (entries) / sizeof (aclent_t), entries);
else
ret = acl (name, SETACL, sizeof (entries) / sizeof (aclent_t), entries);
if (ret < 0)
{
if (errno == ENOSYS)
return chmod_or_fchmod (name, desc, mode);
return -1;
}
}
if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX)))
{
/* We did not call chmod so far, so the special bits have not yet
been set. */
return chmod_or_fchmod (name, desc, mode);
}
return 0;
# endif
# elif HAVE_GETACL /* HP-UX */
struct stat statbuf;
struct acl_entry entries[3];
int ret;
if (desc != -1)
ret = fstat (desc, &statbuf);
else
ret = stat (name, &statbuf);
if (ret < 0)
return -1;
entries[0].uid = statbuf.st_uid;
entries[0].gid = ACL_NSGROUP;
entries[0].mode = (mode >> 6) & 7;
entries[1].uid = ACL_NSUSER;
entries[1].gid = statbuf.st_gid;
entries[1].mode = (mode >> 3) & 7;
entries[2].uid = ACL_NSUSER;
entries[2].gid = ACL_NSGROUP;
entries[2].mode = mode & 7;
if (desc != -1)
ret = fsetacl (desc, sizeof (entries) / sizeof (struct acl_entry), entries);
else
ret = setacl (name, sizeof (entries) / sizeof (struct acl_entry), entries);
if (ret < 0)
{
if (errno == ENOSYS || errno == EOPNOTSUPP)
return chmod_or_fchmod (name, desc, mode);
return -1;
}
if (mode & (S_ISUID | S_ISGID | S_ISVTX))
{
/* We did not call chmod so far, so the special bits have not yet
been set. */
return chmod_or_fchmod (name, desc, mode);
}
return 0;
# elif HAVE_ACLX_GET && 0 /* AIX */
/* TODO: use aclx_fput or aclx_put, respectively */
# elif HAVE_STATACL /* older AIX */
union { struct acl a; char room[128]; } u;
int ret;
u.a.acl_len = (char *) &u.a.acl_ext[0] - (char *) &u.a; /* no entries */
u.a.acl_mode = mode & ~(S_IXACL | 0777);
u.a.u_access = (mode >> 6) & 7;
u.a.g_access = (mode >> 3) & 7;
u.a.o_access = mode & 7;
if (desc != -1)
ret = fchacl (desc, &u.a, u.a.acl_len);
else
ret = chacl (name, &u.a, u.a.acl_len);
if (ret < 0 && errno == ENOSYS)
return chmod_or_fchmod (name, desc, mode);
return ret;
# else /* Unknown flavor of ACLs */
return chmod_or_fchmod (name, desc, mode);
# endif
#else /* !USE_ACL */
return chmod_or_fchmod (name, desc, mode);
#endif
}
/* As with qset_acl, but also output a diagnostic on failure. */
int
set_acl (char const *name, int desc, mode_t mode)
{
int r = qset_acl (name, desc, mode);
if (r != 0)
error (0, errno, _("setting permissions for %s"), quote (name));
return r;
}
| [
"karun.matharu@gmail.com"
] | karun.matharu@gmail.com |
948e364683f332d144bf6d437d28a6a7d46fb64d | 736d927ce30479ea40a400c006cdcec3105ac6dc | /src/drivers/sam/drivers/rtc/rtc.c | b36f90bb58c3d034119cd374d4c9bc9696c5ac35 | [
"MIT"
] | permissive | digitalbitbox/mcu | fd14a1219d332d261fe12e57a699cdac423c5d12 | 3b1d88338aef50f98d9bacead3063ba8a5fb97bd | refs/heads/master | 2023-05-26T23:42:38.474146 | 2023-05-16T12:52:18 | 2023-05-16T12:52:18 | 28,983,102 | 71 | 56 | NOASSERTION | 2023-05-16T12:52:50 | 2015-01-08T19:51:09 | C | UTF-8 | C | false | false | 22,171 | c | /**
* \file
*
* \brief Real-Time Clock (RTC) driver for SAM.
*
* Copyright (c) 2011 - 2014 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* 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.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
*
* \asf_license_stop
*
*/
#include "rtc.h"
/// @cond 0
/**INDENT-OFF**/
#ifdef __cplusplus
extern "C" {
#endif
/**INDENT-ON**/
/// @endcond
/**
* \defgroup sam_drivers_rtc_group Real-Time Clock (RTC)
*
* See \ref sam_rtc_quickstart.
*
* The RTC provides a full binary-coded decimal (BCD) clock that includes
* century (19/20), year (with leap years), month, date, day, hour, minute
* and second.
*
* @{
*/
/* RTC Write Protect Key "RTC" in ASCII */
#define RTC_WP_KEY (0x525443)
/* The BCD code shift value */
#define BCD_SHIFT 4
/* The BCD code mask value */
#define BCD_MASK 0xfu
/* The BCD mul/div factor value */
#define BCD_FACTOR 10
/**
* \brief Set the RTC hour mode.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_mode 1 for 12-hour mode, 0 for 24-hour mode.
*/
void rtc_set_hour_mode(Rtc *p_rtc, uint32_t ul_mode)
{
if (ul_mode) {
p_rtc->RTC_MR |= RTC_MR_HRMOD;
} else {
p_rtc->RTC_MR &= (~RTC_MR_HRMOD);
}
}
/**
* \brief Get the RTC hour mode.
*
* \param p_rtc Pointer to an RTC instance.
*
* \return 1 for 12-hour mode, 0 for 24-hour mode.
*/
uint32_t rtc_get_hour_mode(Rtc *p_rtc)
{
uint32_t ul_temp = p_rtc->RTC_MR;
if (ul_temp & RTC_MR_HRMOD) {
return 1;
} else {
return 0;
}
}
/**
* \brief Enable RTC interrupts.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_sources Interrupts to be enabled.
*/
void rtc_enable_interrupt(Rtc *p_rtc, uint32_t ul_sources)
{
p_rtc->RTC_IER = ul_sources;
}
/**
* \brief Disable RTC interrupts.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_sources Interrupts to be disabled.
*/
void rtc_disable_interrupt(Rtc *p_rtc, uint32_t ul_sources)
{
p_rtc->RTC_IDR = ul_sources;
}
/**
* \brief Read RTC interrupt mask.
*
* \param p_rtc Pointer to an RTC instance.
*
* \return The interrupt mask value.
*/
uint32_t rtc_get_interrupt_mask(Rtc *p_rtc)
{
return p_rtc->RTC_IMR;
}
/**
* \brief Get the RTC time value.
*
* \param p_rtc Pointer to an RTC instance.
* \param pul_hour Current hour, 24-hour mode.
* \param pul_minute Current minute.
* \param pul_second Current second.
*/
void rtc_get_time(Rtc *p_rtc, uint32_t *pul_hour, uint32_t *pul_minute,
uint32_t *pul_second)
{
uint32_t ul_time;
uint32_t ul_temp;
/* Get the current RTC time (multiple reads are necessary to insure a stable value). */
ul_time = p_rtc->RTC_TIMR;
while (ul_time != p_rtc->RTC_TIMR) {
ul_time = p_rtc->RTC_TIMR;
}
/* Hour */
if (pul_hour) {
ul_temp = (ul_time & RTC_TIMR_HOUR_Msk) >> RTC_TIMR_HOUR_Pos;
*pul_hour = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
if ((ul_time & RTC_TIMR_AMPM) == RTC_TIMR_AMPM) {
*pul_hour += 12;
}
}
/* Minute */
if (pul_minute) {
ul_temp = (ul_time & RTC_TIMR_MIN_Msk) >> RTC_TIMR_MIN_Pos;
*pul_minute = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Second */
if (pul_second) {
ul_temp = (ul_time & RTC_TIMR_SEC_Msk) >> RTC_TIMR_SEC_Pos;
*pul_second = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
}
/**
* \brief Set the RTC time value.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_hour Current hour, 24-hour mode.
* \param ul_minute Current minute.
* \param ul_second Current second.
*
* \return 0 for OK, else invalid setting.
*/
uint32_t rtc_set_time(Rtc *p_rtc, uint32_t ul_hour, uint32_t ul_minute,
uint32_t ul_second)
{
uint32_t ul_time = 0;
/* If 12-hour mode, set AMPM bit */
if ((p_rtc->RTC_MR & RTC_MR_HRMOD) == RTC_MR_HRMOD) {
if (ul_hour > 12) {
ul_hour -= 12;
ul_time |= RTC_TIMR_AMPM;
}
}
/* Hour */
ul_time |= ((ul_hour / BCD_FACTOR) << (RTC_TIMR_HOUR_Pos + BCD_SHIFT)) |
((ul_hour % BCD_FACTOR) << RTC_TIMR_HOUR_Pos);
/* Minute */
ul_time |= ((ul_minute / BCD_FACTOR) << (RTC_TIMR_MIN_Pos + BCD_SHIFT)) |
((ul_minute % BCD_FACTOR) << RTC_TIMR_MIN_Pos);
/* Second */
ul_time |= ((ul_second / BCD_FACTOR) << (RTC_TIMR_SEC_Pos + BCD_SHIFT)) |
((ul_second % BCD_FACTOR) << RTC_TIMR_SEC_Pos);
/* Update time register. Check the spec for the flow. */
p_rtc->RTC_CR |= RTC_CR_UPDTIM;
while ((p_rtc->RTC_SR & RTC_SR_ACKUPD) != RTC_SR_ACKUPD);
p_rtc->RTC_SCCR = RTC_SCCR_ACKCLR;
p_rtc->RTC_TIMR = ul_time;
p_rtc->RTC_CR &= (~RTC_CR_UPDTIM);
p_rtc->RTC_SCCR |= RTC_SCCR_SECCLR;
return (p_rtc->RTC_VER & RTC_VER_NVTIM);
}
/**
* \brief Set the RTC alarm time value.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_hour_flag 1 for setting, 0 for not setting.
* \param ul_hour Alarm hour value, 24-hour mode.
* \param ul_minute_flag 1 for setting, 0 for not setting.
* \param ul_minute Alarm minute value.
* \param ul_second_flag 1 for setting, 0 for not setting.
* \param ul_second Alarm second value.
*
* \return 0 for OK, else invalid setting.
*/
uint32_t rtc_set_time_alarm(Rtc *p_rtc,
uint32_t ul_hour_flag, uint32_t ul_hour,
uint32_t ul_minute_flag, uint32_t ul_minute,
uint32_t ul_second_flag, uint32_t ul_second)
{
uint32_t ul_alarm = 0;
/* Hour alarm setting */
if (ul_hour_flag) {
/* If 12-hour mode, set AMPM bit */
if ((p_rtc->RTC_MR & RTC_MR_HRMOD) == RTC_MR_HRMOD) {
if (ul_hour > 12) {
ul_hour -= 12;
ul_alarm |= RTC_TIMR_AMPM;
}
}
ul_alarm |= RTC_TIMALR_HOUREN | ((ul_hour / BCD_FACTOR) <<
(RTC_TIMR_HOUR_Pos + BCD_SHIFT)) |
((ul_hour % BCD_FACTOR) << RTC_TIMR_HOUR_Pos);
}
/* Minute alarm setting */
if (ul_minute_flag) {
ul_alarm |= RTC_TIMALR_MINEN | ((ul_minute / BCD_FACTOR) <<
(RTC_TIMR_MIN_Pos + BCD_SHIFT)) |
((ul_minute % BCD_FACTOR) << RTC_TIMR_MIN_Pos);
}
/* Second alarm setting */
if (ul_second_flag) {
ul_alarm |= RTC_TIMALR_SECEN | ((ul_second / BCD_FACTOR) <<
(RTC_TIMR_SEC_Pos + BCD_SHIFT)) |
((ul_second % BCD_FACTOR) << RTC_TIMR_SEC_Pos);
}
p_rtc->RTC_TIMALR = ul_alarm;
return (p_rtc->RTC_VER & RTC_VER_NVTIMALR);
}
/**
* \brief Get the RTC date value.
*
* \param p_rtc Pointer to an RTC instance.
* \param pul_year Current year.
* \param pul_month Current month.
* \param pul_day Current day.
* \param pul_week Current day in current week.
*/
void rtc_get_date(Rtc *p_rtc, uint32_t *pul_year, uint32_t *pul_month,
uint32_t *pul_day, uint32_t *pul_week)
{
uint32_t ul_date;
uint32_t ul_cent;
uint32_t ul_temp;
/* Get the current date (multiple reads are necessary to insure a stable value). */
ul_date = p_rtc->RTC_CALR;
while (ul_date != p_rtc->RTC_CALR) {
ul_date = p_rtc->RTC_CALR;
}
/* Retrieve year */
if (pul_year) {
ul_temp = (ul_date & RTC_CALR_CENT_Msk) >> RTC_CALR_CENT_Pos;
ul_cent = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
ul_temp = (ul_date & RTC_CALR_YEAR_Msk) >> RTC_CALR_YEAR_Pos;
*pul_year = (ul_cent * BCD_FACTOR * BCD_FACTOR) +
(ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Retrieve month */
if (pul_month) {
ul_temp = (ul_date & RTC_CALR_MONTH_Msk) >> RTC_CALR_MONTH_Pos;
*pul_month = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Retrieve day */
if (pul_day) {
ul_temp = (ul_date & RTC_CALR_DATE_Msk) >> RTC_CALR_DATE_Pos;
*pul_day = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Retrieve week */
if (pul_week) {
*pul_week = ((ul_date & RTC_CALR_DAY_Msk) >> RTC_CALR_DAY_Pos);
}
}
/**
* \brief Set the RTC date.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_year Current year.
* \param ul_month Current month.
* \param ul_day Current day.
* \param ul_week Current day in current week.
*
* \return 0 for OK, else invalid setting.
*/
uint32_t rtc_set_date(Rtc *p_rtc, uint32_t ul_year, uint32_t ul_month,
uint32_t ul_day, uint32_t ul_week)
{
uint32_t ul_date = 0;
/* Cent */
ul_date |= ((ul_year / BCD_FACTOR / BCD_FACTOR / BCD_FACTOR) <<
(RTC_CALR_CENT_Pos + BCD_SHIFT) |
((ul_year / BCD_FACTOR / BCD_FACTOR) % BCD_FACTOR) << RTC_CALR_CENT_Pos);
/* Year */
ul_date |= (((ul_year / BCD_FACTOR) % BCD_FACTOR) <<
(RTC_CALR_YEAR_Pos + BCD_SHIFT)) |
((ul_year % BCD_FACTOR) << RTC_CALR_YEAR_Pos);
/* Month */
ul_date |= ((ul_month / BCD_FACTOR) << (RTC_CALR_MONTH_Pos + BCD_SHIFT)) |
((ul_month % BCD_FACTOR) << RTC_CALR_MONTH_Pos);
/* Week */
ul_date |= (ul_week << RTC_CALR_DAY_Pos);
/* Day */
ul_date |= ((ul_day / BCD_FACTOR) << (RTC_CALR_DATE_Pos + BCD_SHIFT)) |
((ul_day % BCD_FACTOR) << RTC_CALR_DATE_Pos);
/* Update calendar register. Check the spec for the flow. */
p_rtc->RTC_CR |= RTC_CR_UPDCAL;
while ((p_rtc->RTC_SR & RTC_SR_ACKUPD) != RTC_SR_ACKUPD);
p_rtc->RTC_SCCR = RTC_SCCR_ACKCLR;
p_rtc->RTC_CALR = ul_date;
p_rtc->RTC_CR &= (~RTC_CR_UPDCAL);
/* Clear SECENV in SCCR */
p_rtc->RTC_SCCR |= RTC_SCCR_SECCLR;
return (p_rtc->RTC_VER & RTC_VER_NVCAL);
}
/**
* \brief Set the RTC alarm date value.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_month_flag 1 for setting, 0 for not setting.
* \param ul_month Alarm month value.
* \param ul_day_flag 1 for setting, 0 for not setting.
* \param ul_day Alarm day value.
*
* \return 0 for OK, else invalid setting.
*/
uint32_t rtc_set_date_alarm(Rtc *p_rtc,
uint32_t ul_month_flag, uint32_t ul_month,
uint32_t ul_day_flag, uint32_t ul_day)
{
uint32_t ul_alarm = 0;
/* Month alarm setting */
if (ul_month_flag) {
ul_alarm |= RTC_CALALR_MTHEN | ((ul_month / BCD_FACTOR) <<
(RTC_CALR_MONTH_Pos + BCD_SHIFT)) |
((ul_month % BCD_FACTOR) << RTC_CALR_MONTH_Pos);
}
/* Day alarm setting */
if (ul_day_flag) {
ul_alarm |= RTC_CALALR_DATEEN | ((ul_day / BCD_FACTOR) <<
(RTC_CALR_DATE_Pos + BCD_SHIFT)) |
((ul_day % BCD_FACTOR) << RTC_CALR_DATE_Pos);
}
/* Set alarm */
p_rtc->RTC_CALALR = ul_alarm;
return (p_rtc->RTC_VER & RTC_VER_NVCALALR);
}
/**
* \brief Clear the RTC time alarm setting.
*
* \param p_rtc Pointer to an RTC instance.
*/
void rtc_clear_time_alarm(Rtc *p_rtc)
{
p_rtc->RTC_TIMALR = 0;
}
/**
* \brief Clear the RTC date alarm setting.
*
* \param p_rtc Pointer to an RTC instance.
*/
void rtc_clear_date_alarm(Rtc *p_rtc)
{
/* Need a valid value without enabling */
p_rtc->RTC_CALALR = RTC_CALALR_MONTH(0x01) | RTC_CALALR_DATE(0x01);
}
/**
* \brief Get the RTC status.
*
* \param p_rtc Pointer to an RTC instance.
*
* \return Status of the RTC.
*/
uint32_t rtc_get_status(Rtc *p_rtc)
{
return (p_rtc->RTC_SR);
}
/**
* \brief Set the RTC SCCR to clear status bits.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_clear Some flag bits which will be cleared.
*/
void rtc_clear_status(Rtc *p_rtc, uint32_t ul_clear)
{
p_rtc->RTC_SCCR = ul_clear;
}
#if ((SAM3S8) || (SAM3SD8) || (SAM4S) || (SAM4N) || (SAM4C) || (SAMG) || (SAM4CP) || (SAM4CM))
/**
* \brief Set the RTC calendar mode.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_mode 1 for Persian mode,0 for Gregorian mode.
*/
void rtc_set_calendar_mode(Rtc *p_rtc, uint32_t ul_mode)
{
if (ul_mode) {
p_rtc->RTC_MR |= RTC_MR_PERSIAN;
} else {
p_rtc->RTC_MR &= (~RTC_MR_PERSIAN);
}
}
/**
* \brief Set the RTC calibration.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_direction_ppm Positive/negative correction.
* \param ul_correction Correction value.
* \param ul_range_ppm Low/high range correction.
*/
void rtc_set_calibration(Rtc *p_rtc, uint32_t ul_direction_ppm,
uint32_t ul_correction, uint32_t ul_range_ppm)
{
uint32_t ul_temp;
ul_temp = p_rtc->RTC_MR;
if (ul_direction_ppm) {
ul_temp |= RTC_MR_NEGPPM;
} else {
ul_temp &= (~RTC_MR_NEGPPM);
}
ul_temp |= RTC_MR_CORRECTION(ul_correction);
if (ul_range_ppm) {
ul_temp |= RTC_MR_HIGHPPM;
} else {
ul_temp &= (~RTC_MR_HIGHPPM);
}
p_rtc->RTC_MR = ul_temp;
}
#endif
#if ((SAM3S8) || (SAM3SD8) || (SAM4S) || (SAM4C) || (SAMG) || (SAM4CP) || (SAM4CM))
/**
* \brief Set the RTC output waveform.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_channel Output channel selection.
* \param ul_value Output source selection value.
*/
void rtc_set_waveform(Rtc *p_rtc, uint32_t ul_channel, uint32_t ul_value)
{
if (ul_channel == 0) {
switch (ul_value) {
case 0:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_NO_WAVE;
break;
case 1:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_FREQ1HZ;
break;
case 2:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_FREQ32HZ;
break;
case 3:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_FREQ64HZ;
break;
case 4:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_FREQ512HZ;
break;
#if (!SAMG)
case 5:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_ALARM_TOGGLE;
break;
#endif
case 6:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_ALARM_FLAG;
break;
#if (!SAMG)
case 7:
p_rtc->RTC_MR &= ~RTC_MR_OUT0_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT0_PROG_PULSE;
break;
#endif
default:
break;
}
} else {
#if (!SAM4C && !SAM4CP && !SAM4CM)
switch (ul_value) {
case 0:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_NO_WAVE;
break;
case 1:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_FREQ1HZ;
break;
case 2:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_FREQ32HZ;
break;
case 3:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_FREQ64HZ;
break;
case 4:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_FREQ512HZ;
break;
#if (!SAMG)
case 5:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_ALARM_TOGGLE;
break;
#endif
case 6:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_ALARM_FLAG;
break;
#if (!SAMG)
case 7:
p_rtc->RTC_MR &= ~RTC_MR_OUT1_Msk;
p_rtc->RTC_MR |= RTC_MR_OUT1_PROG_PULSE;
break;
#endif
default:
break;
}
#endif
}
}
#if ((SAM3S8) || (SAM3SD8) || (SAM4S) || (SAM4C))
/**
* \brief Set the pulse output waveform parameters.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_time_high High duration of the output pulse.
* \param ul_period Period of the output pulse.
*/
void rtc_set_pulse_parameter(Rtc *p_rtc, uint32_t ul_time_high,
uint32_t ul_period)
{
uint32_t ul_temp;
ul_temp = p_rtc->RTC_MR;
ul_temp |= (RTC_MR_THIGH_Msk & ((ul_time_high) << RTC_MR_THIGH_Pos));
ul_temp |= (RTC_MR_TPERIOD_Msk & ((ul_period) << RTC_MR_TPERIOD_Pos));
p_rtc->RTC_MR = ul_temp;
}
#endif
#endif
#if ((SAM3N) || (SAM3U) || (SAM3XA))
/**
* \brief Enable or disable write protection of RTC registers.
*
* \param p_rtc Pointer to an RTC instance.
* \param ul_enable 1 to enable, 0 to disable.
*/
void rtc_set_writeprotect(Rtc *p_rtc, uint32_t ul_enable)
{
if (ul_enable) {
p_rtc->RTC_WPMR = RTC_WPMR_WPKEY(RTC_WP_KEY) | RTC_WPMR_WPEN;
} else {
p_rtc->RTC_WPMR = RTC_WPMR_WPKEY(RTC_WP_KEY);
}
}
#endif /* ((SAM3N) || (SAM3U) || (SAM3XA)) */
#if SAM4C || SAM4CP || SAM4CM
/**
* \brief Get the RTC tamper time value.
*
* \note This function should be called before rtc_get_tamper_source()
* function call, Otherwise the tamper time will be cleared.
*
* \param p_rtc Pointer to an RTC instance.
* \param pul_hour Current hour, 24-hour mode.
* \param pul_minute Current minute.
* \param pul_second Current second.
* \param reg_num Current tamper register set number.
*/
void rtc_get_tamper_time(Rtc *p_rtc, uint32_t *pul_hour, uint32_t *pul_minute,
uint32_t *pul_second, uint8_t reg_num)
{
uint32_t ul_time;
uint32_t ul_temp;
/* Get the current RTC time (multiple reads are to insure a stable value). */
ul_time = p_rtc->RTC_TS[reg_num].RTC_TSTR;
while (ul_time != p_rtc->RTC_TS[reg_num].RTC_TSTR) {
ul_time = p_rtc->RTC_TS[reg_num].RTC_TSTR;
}
/* Hour */
if (pul_hour) {
ul_temp = (ul_time & RTC_TSTR_HOUR_Msk) >> RTC_TSTR_HOUR_Pos;
*pul_hour = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
if ((ul_time & RTC_TSTR_AMPM) == RTC_TSTR_AMPM) {
*pul_hour += 12;
}
}
/* Minute */
if (pul_minute) {
ul_temp = (ul_time & RTC_TSTR_MIN_Msk) >> RTC_TSTR_MIN_Pos;
*pul_minute = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Second */
if (pul_second) {
ul_temp = (ul_time & RTC_TSTR_SEC_Msk) >> RTC_TSTR_SEC_Pos;
*pul_second = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
}
/**
* \brief Get the RTC tamper date.
*
* \note This function should be called before rtc_get_tamper_source()
* function call, Otherwise the tamper date will be cleared.
*
* \param p_rtc Pointer to an RTC instance.
* \param pul_year Current year.
* \param pul_month Current month.
* \param pul_day Current day.
* \param pul_week Current day in current week.
* \param reg_num Current tamper register set number.
*/
void rtc_get_tamper_date(Rtc *p_rtc, uint32_t *pul_year, uint32_t *pul_month,
uint32_t *pul_day, uint32_t *pul_week, uint8_t reg_num)
{
uint32_t ul_date;
uint32_t ul_cent;
uint32_t ul_temp;
/* Get the current date (multiple reads are to insure a stable value). */
ul_date = p_rtc->RTC_TS[reg_num].RTC_TSDR;
while (ul_date != p_rtc->RTC_TS[reg_num].RTC_TSDR) {
ul_date = p_rtc->RTC_TS[reg_num].RTC_TSDR;
}
/* Retrieve year */
if (pul_year) {
ul_temp = (ul_date & RTC_TSDR_CENT_Msk) >> RTC_TSDR_CENT_Pos;
ul_cent = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
ul_temp = (ul_date & RTC_TSDR_YEAR_Msk) >> RTC_TSDR_YEAR_Pos;
*pul_year = (ul_cent * BCD_FACTOR * BCD_FACTOR) +
(ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Retrieve month */
if (pul_month) {
ul_temp = (ul_date & RTC_TSDR_MONTH_Msk) >> RTC_TSDR_MONTH_Pos;
*pul_month = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Retrieve day */
if (pul_day) {
ul_temp = (ul_date & RTC_TSDR_DATE_Msk) >> RTC_TSDR_DATE_Pos;
*pul_day = (ul_temp >> BCD_SHIFT) * BCD_FACTOR + (ul_temp & BCD_MASK);
}
/* Retrieve week */
if (pul_week) {
*pul_week = ((ul_date & RTC_TSDR_DAY_Msk) >> RTC_TSDR_DAY_Pos);
}
}
/**
* \brief Get the RTC tamper source.
*
* \param p_rtc Pointer to an RTC instance.
* \param reg_num Current tamper register set number.
*
* \return Tamper source.
*/
uint32_t rtc_get_tamper_source(Rtc *p_rtc, uint8_t reg_num)
{
return (p_rtc->RTC_TS[reg_num].RTC_TSSR & RTC_TSSR_TSRC_Msk) >>
RTC_TSSR_TSRC_Pos;
}
/**
* \brief Get the RTC tamper event counter.
*
* \note This function should be called before rtc_get_tamper_source()
* function call, Otherwise the tamper event counter will be cleared.
*
* \param p_rtc Pointer to an RTC instance.
*
* \return Tamper event counter
*/
uint32_t rtc_get_tamper_event_counter(Rtc *p_rtc)
{
return (p_rtc->RTC_TS[0].RTC_TSTR & RTC_TSTR_TEVCNT_Msk) >>
RTC_TSTR_TEVCNT_Pos;
}
/**
* \brief Check the system is in backup mode when RTC tamper event happen.
*
* \note This function should be called before rtc_get_tamper_source()
* function call, Otherwise the flag indicates tamper occur in backup
* mode will be cleared.
*
* \param p_rtc Pointer to an RTC instance.
* \param reg_num Current tamper register set number.
*
* \return True - The system is in backup mode when the tamper event occurs.
* Flase - The system is different from backup mode.
*/
bool rtc_is_tamper_occur_in_backup_mode(Rtc *p_rtc, uint8_t reg_num)
{
if(p_rtc->RTC_TS[reg_num].RTC_TSTR & RTC_TSTR_BACKUP) {
return true;
} else {
return false;
}
}
#endif
//@}
/// @cond 0
/**INDENT-OFF**/
#ifdef __cplusplus
}
#endif
/**INDENT-ON**/
/// @endcond
| [
"digitalbitbox@gmail.com"
] | digitalbitbox@gmail.com |
7d914812593a0c61f99d5c0560198912e6089d56 | 8eea0097f368764fb9b443b8a90873e09f48bb24 | /jianzhiOffer/print_1ton00.c | 5e05af993804dd8c696f6f15fd9777070a49e951 | [] | no_license | cfs6/DSandAlgorithm | 4fb5156527b77908b9fce885ed214969f85e8e5b | f792f9308c241ba49828d108eb830a7382a2277b | refs/heads/master | 2021-07-03T22:49:28.431195 | 2020-12-13T13:27:03 | 2020-12-13T13:27:03 | 205,761,720 | 2 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,557 | c | //print 1 to at most n-digit number (Big number)
#include<iostream>
#include<string>
void print1toMaxOfDigit(long long n){
if(n < 0)
return;
char* number = new char[n+1];
number[n] = '\0';
for(int i = 0; i < n+1; ++i)
number[i] = 0;
int sum = 1;
int carry = 0;
bool overFlow = false;
while(!overFlow){
int carry = 0;
for(int i = n-1; i >= 0; ++i){
sum = number[i] + '0' + carry;
if(i = n-1)
sum++;
if(sum >= 10){
if(i == 0)
overFlow = true;
else{
sum -= 10;
carry = 1;
number[i] = '0' + sum;
}
}
else{
number[i] = '0' + sum;
break;
}
}
print(number);
}
}
void print(char* number){
int beginning = 0;
for(int i = 0; i < number.size(); ++i){
if(number[i] != '0')
beginning = 1;
if(beginning)
std::cout<<number[i];
}
std::cout<<std::endl;
}
// Another way
void print1ton(int n){
if(n <= 0)
return;
ing length = n;
char* number = new char[length+1];
number[length] = '\0';
for(int k = 0; k < length; ++k)
number[k] = '0';
for(int i = 0; i < 10; ++i){
number[i] = '0' + i;
print1tonRecursively(number, n, 0);
}
}
void print1tonRecursively(char* number, int length, int index){
if(index == length-1)
print(number);
for(int i = 0; i < 10; ++i){
number[index] = '0' + i;
print1tonRecursively(number, length, index+1);
}
}
void print(const char* number){
bool beginning = false;
for(int i = 0; i < number.size(); ++i){
if(number[i] != 0)
beginning =true;
if(beginning == true)
std::cout<<number[i];
}
std::cout<<std::endl;
}
| [
"2766607313@qq.com"
] | 2766607313@qq.com |
3e8325e7f9a6840e23a8587f9da99b60f2c2badd | f683acda79d81a0c2e47ad43eecef9b5a159fabb | /KernPro/modules/myhello.mod.c | 9b6b62d85e7fdc0319dbb6b9f5adc97f80b6e878 | [] | no_license | sagarramdev173/techveda | 1e68df8474d98d108e5fd31e5bc50e417750732e | 54efe14c8366d3af209f482136025d4598d99b53 | refs/heads/master | 2023-03-15T23:41:37.386136 | 2019-05-31T04:32:50 | 2019-05-31T04:32:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 507 | c | #include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
MODULE_INFO(vermagic, VERMAGIC_STRING);
__visible struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
static const char __module_depends[]
__used
__attribute__((section(".modinfo"))) =
"depends=";
MODULE_INFO(srcversion, "552448B440BF2343F990B55");
| [
"vijay.dhoki2013@gmail.com"
] | vijay.dhoki2013@gmail.com |
e117912502b6ec28aa2bee15cf3530f3199b51ca | 2a48f65c767085f86cfc65d559c5ff6499f35ed9 | /src/peripheral/include/flash.h | 90c9e3be6c89e4999301e7021c753ddb3b25c0f2 | [
"MIT"
] | permissive | peris-trash/openinput-prototype | 84c346e2817aaa1aa218f5b248a91ece1de7fd13 | 55975677b0192028ba5e926808e1312661a260de | refs/heads/master | 2022-04-13T04:06:37.222520 | 2020-01-24T14:31:35 | 2020-01-24T14:31:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 536 | h | #ifndef __FLASH_H__
#define __FLASH_H__
#include <stm32f10x.h>
#define FLASH_SIZE (((uint32_t)*(volatile uint16_t *)0x1FFFF7E0) << 10)
#define FLASH_PAGE_SIZE 2048
#define FLASH_PAGE_COUNT (FLASH_SIZE / FLASH_PAGE_SIZE)
#define FLASH_MAX_ADDRESS (FLASH_BASE + FLASH_SIZE - 1)
void flash_init();
void flash_latency_config(uint32_t ulSystemClock);
void flash_lock();
void flash_unlock();
void flash_page_erase(uint32_t ulAddress);
void flash_page_write(uint32_t ulAddress, uint8_t *pubData, uint32_t ulSize);
#endif
| [
"silvagracarafael@gmail.com"
] | silvagracarafael@gmail.com |
bfa09c387807d0b10e8d1ae13ddc33568294c4be | 5c255f911786e984286b1f7a4e6091a68419d049 | /vulnerable_code/79893c31-5780-49a0-9acb-69871ddac7df.c | 6d30461a0093a6166e82934ff4f0aaea0cfb092a | [] | no_license | nmharmon8/Deep-Buffer-Overflow-Detection | 70fe02c8dc75d12e91f5bc4468cf260e490af1a4 | e0c86210c86afb07c8d4abcc957c7f1b252b4eb2 | refs/heads/master | 2021-09-11T19:09:59.944740 | 2018-04-06T16:26:34 | 2018-04-06T16:26:34 | 125,521,331 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 584 | c | #include <string.h>
#include <stdio.h>
int main() {
int i=0;
int j=122;
int k;
int l;
k = 53;
l = 64;
k = i/j;
l = i/j;
l = l%j;
l = i%j;
l = l-j;
k = k-k*i;
//variables
//random
/* START VULNERABILITY */
int a;
char b[38];
char c[82];
a = 0;
while (a < strlen(b)) {
//random
/* START BUFFER SET */
*((char *)c + a) = *((char *)b + a);
/* END BUFFER SET */
a++;
}
/* END VULNERABILITY */
//random
printf("%d%d\n",k,i);
return 0;
}
| [
"nharmon8@gmail.com"
] | nharmon8@gmail.com |
7f81cb249e89df9cf8c8754029dcaaf21aea616d | 976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f | /source/linux/drivers/spi/extr_spi-altera.c_altera_spi_txrx.c | e5e21ee6ffb42d612579122198fb6313c043899e | [] | no_license | isabella232/AnghaBench | 7ba90823cf8c0dd25a803d1688500eec91d1cf4e | 9a5f60cdc907a0475090eef45e5be43392c25132 | refs/heads/master | 2023-04-20T09:05:33.024569 | 2021-05-07T18:36:26 | 2021-05-07T18:36:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 2,161 | c | #define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
struct spi_transfer {int len; int /*<<< orphan*/ bits_per_word; int /*<<< orphan*/ rx_buf; int /*<<< orphan*/ tx_buf; } ;
struct spi_master {int dummy; } ;
struct spi_device {int dummy; } ;
struct altera_spi {int count; int bytes_per_word; int len; scalar_t__ irq; scalar_t__ base; int /*<<< orphan*/ imr; int /*<<< orphan*/ rx; int /*<<< orphan*/ tx; } ;
/* Variables and functions */
scalar_t__ ALTERA_SPI_CONTROL ;
int /*<<< orphan*/ ALTERA_SPI_CONTROL_IRRDY_MSK ;
scalar_t__ ALTERA_SPI_STATUS ;
int ALTERA_SPI_STATUS_RRDY_MSK ;
int DIV_ROUND_UP (int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ altera_spi_rx_word (struct altera_spi*) ;
int /*<<< orphan*/ altera_spi_tx_word (struct altera_spi*) ;
int /*<<< orphan*/ cpu_relax () ;
int readl (scalar_t__) ;
int /*<<< orphan*/ spi_finalize_current_transfer (struct spi_master*) ;
struct altera_spi* spi_master_get_devdata (struct spi_master*) ;
int /*<<< orphan*/ writel (int /*<<< orphan*/ ,scalar_t__) ;
__attribute__((used)) static int altera_spi_txrx(struct spi_master *master,
struct spi_device *spi, struct spi_transfer *t)
{
struct altera_spi *hw = spi_master_get_devdata(master);
hw->tx = t->tx_buf;
hw->rx = t->rx_buf;
hw->count = 0;
hw->bytes_per_word = DIV_ROUND_UP(t->bits_per_word, 8);
hw->len = t->len / hw->bytes_per_word;
if (hw->irq >= 0) {
/* enable receive interrupt */
hw->imr |= ALTERA_SPI_CONTROL_IRRDY_MSK;
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
/* send the first byte */
altera_spi_tx_word(hw);
} else {
while (hw->count < hw->len) {
altera_spi_tx_word(hw);
while (!(readl(hw->base + ALTERA_SPI_STATUS) &
ALTERA_SPI_STATUS_RRDY_MSK))
cpu_relax();
altera_spi_rx_word(hw);
}
spi_finalize_current_transfer(master);
}
return t->len;
} | [
"brenocfg@gmail.com"
] | brenocfg@gmail.com |
278df5c1d8db7bf11840073172702c86bd724037 | 55f54c9d18e3781255c157d63381579261dde405 | /Code/Tools/FBuild/FBuildTest/Data/TestCache/LightCache_IncludeUsingMacro2/header1.h | 1125b8fd95125b317a60403c677ba1a53b92134f | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | fastbuild/fastbuild | 8f5f94802c6cce54d903936c8551fd8791479001 | 1b3935069d29b965a9d1d6798d9cf651319dbe87 | refs/heads/main | 2023-08-22T19:28:12.587510 | 2023-08-19T02:56:25 | 2023-08-19T02:56:25 | 32,647,696 | 1,175 | 409 | null | 2023-08-23T22:40:15 | 2015-03-21T19:53:07 | C++ | UTF-8 | C | false | false | 97 | h |
// define macro for use by file that includes this header
#define INCLUDE_VIA_MACRO "header2.h"
| [
"franta.fulin@gmail.com"
] | franta.fulin@gmail.com |
d80eb820ad456b004779b5ef8cf7523e27095a85 | a29296c51e6ffdb77dc6399a32483c8e22c91a25 | /facebookApp/ios/Pods/Headers/Private/ReactABI16_0_0/ABI16_0_0RNSVGEllipse.h | 228d5cdd258cb3c3591fe9a407706a600f0625d6 | [
"MIT",
"CC-BY-4.0",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | guypy/facebook-hack | dd2d6bc297775d837391b1c4d0ca3486e37cd0bd | 84dd65f6d8b55d3197267dfbe0e71cb61bcb3303 | refs/heads/master | 2021-01-19T06:00:39.668390 | 2017-08-17T22:27:31 | 2017-08-17T22:27:31 | 100,588,845 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 104 | h | ../../../../versioned-react-native/ABI16_0_0/Exponent/Modules/Api/Components/Svg/ABI16_0_0RNSVGEllipse.h | [
"guypinchuk@gmail.com"
] | guypinchuk@gmail.com |
4afba76d5dc3878b65740f4bef246a87191673a5 | df066a277e96d312d51b175ead50ea0879f54a3f | /inferno/bios/system.test.c | 4c611d3d1644de5be98cbdb6c4b258bc992459a0 | [] | no_license | clownfysh/cf | e3eb79e3c658c086dbc5483e8a8a1820f66f4403 | 2f847946f001c56c558a6ba9be1081d453d80c91 | refs/heads/master | 2021-06-23T10:59:13.041034 | 2016-12-09T03:34:10 | 2016-12-09T03:34:10 | 786,723 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 86 | c | #include "cf/inferno/bios/system.h"
int main(int argc, char *argv[])
{
return 0;
}
| [
"clownfysh@gmail.com"
] | clownfysh@gmail.com |
3f9868d1391a02bf5cded10b7bf293e00c6448fc | b477697f95728fbf8d1759a73858860c9620c3ab | /peripheral/power/processor/power_p32mx154f128b.h | 4188adacf285156cf706327c63012959e69c1e62 | [] | no_license | gmuro/harmony-v2_06-framework | 12bcb30c2dc9f4737aab8762da8b25632822d00e | 2196b67de35af9d1126b539b08324cf72ed13521 | refs/heads/master | 2022-12-07T19:24:34.649360 | 2022-11-18T22:16:49 | 2022-11-18T22:16:49 | 190,900,209 | 1 | 1 | null | null | null | null | UTF-8 | C | false | false | 13,880 | h | /* Created by plibgen $Revision: 1.31 $ */
#ifndef _POWER_P32MX154F128B_H
#define _POWER_P32MX154F128B_H
/* Section 1 - Enumerate instances, define constants, VREGs */
#include <xc.h>
#include <stdbool.h>
#include "peripheral/peripheral_common_32bit.h"
/* Default definition used for all API dispatch functions */
#ifndef PLIB_INLINE_API
#define PLIB_INLINE_API extern inline
#endif
/* Default definition used for all other functions */
#ifndef PLIB_INLINE
#define PLIB_INLINE extern inline
#endif
typedef enum {
POWER_ID_0 = 0,
POWER_NUMBER_OF_MODULES = 1
} POWER_MODULE_ID;
typedef enum {
POWER_MODULE_ADC1 = 0x00,
POWER_MODULE_CTMU = 0x08,
POWER_MODULE_CVR = 0x0C,
POWER_MODULE_HLVD = 0x14,
POWER_MODULE_CMP1 = 0x20,
POWER_MODULE_CMP2 = 0x22,
POWER_MODULE_IC1 = 0x40,
POWER_MODULE_IC2 = 0x41,
POWER_MODULE_IC3 = 0x42,
POWER_MODULE_IC4 = 0x43,
POWER_MODULE_IC5 = 0x44,
POWER_MODULE_OC1 = 0x50,
POWER_MODULE_OC2 = 0x51,
POWER_MODULE_OC3 = 0x52,
POWER_MODULE_OC4 = 0x53,
POWER_MODULE_OC5 = 0x54,
POWER_MODULE_TMR1 = 0x60,
POWER_MODULE_TMR2 = 0x61,
POWER_MODULE_TMR3 = 0x62,
POWER_MODULE_TMR4 = 0x63,
POWER_MODULE_TMR5 = 0x64,
POWER_MODULE_UART1 = 0x80,
POWER_MODULE_UART2 = 0x81,
POWER_MODULE_SPI1 = 0x88,
POWER_MODULE_SPI2 = 0x89,
POWER_MODULE_I2C1 = 0x90,
POWER_MODULE_I2C2 = 0x91,
POWER_MODULE_USB = 0x98,
POWER_MODULE_RTCC = 0xA0,
POWER_MODULE_REF_CLK_OUTPUT = 0xA1,
POWER_MODULE_PMP = 0xB0
} POWER_MODULE;
typedef enum {
HLVD_LIMIT_TRIP_POINT_4 = 0x00000100,
HLVD_LIMIT_TRIP_POINT_5 = 0x00000101,
HLVD_LIMIT_TRIP_POINT_6 = 0x00000110,
HLVD_LIMIT_TRIP_POINT_7 = 0x00000111,
HLVD_LIMIT_TRIP_POINT_8 = 0x00001000,
HLVD_LIMIT_TRIP_POINT_9 = 0x00001001,
HLVD_LIMIT_TRIP_POINT_10 = 0x00001010,
HLVD_LIMIT_TRIP_POINT_11 = 0x00001011,
HLVD_LIMIT_TRIP_POINT_12 = 0x00001100,
HLVD_LIMIT_TRIP_POINT_13 = 0x00001101,
HLVD_LIMIT_TRIP_POINT_14 = 0x00001110,
HLVD_LIMIT_ANALOG_INPUT_ON_HLVDIN = 0x00001111
} HLVD_LIMIT;
typedef enum {
HLVD_MODE_LOW_VOLTAGE_DETECTION = 0,
HLVD_MODE_HIGH_VOLTAGE_DETECTION = 1
} HLVD_MODE;
typedef enum {
DEEP_SLEEP_MODULE_RTCC = 0x00001000
} DEEP_SLEEP_MODULE;
typedef enum {
DEEP_SLEEP_WAKE_UP_EVENT_RTCC = 0x00000100,
DEEP_SLEEP_WAKE_UP_EVENT_EXTERNAL_INTERRUPT = 0x00000004
} DEEP_SLEEP_WAKE_UP_EVENT;
typedef enum {
DEEP_SLEEP_EVENT_BOR = 0x00000002,
DEEP_SLEEP_EVENT_RTCC_ALARM = 0x00000008,
DEEP_SLEEP_EVENT_EXTERNAL_INTERRUPT = 0x00000100,
DEEP_SLEEP_EVENT_FAULT_DETECTION = 0x00000080,
DEEP_SLEEP_EVENT_WDT_TIMEOUT = 0x00000010,
DEEP_SLEEP_EVENT_MCLR = 0x00000004
} DEEP_SLEEP_EVENT;
typedef enum {
DEEP_SLEEP_GPR_0 = 0x00,
DEEP_SLEEP_GPR_1 = 0x01,
DEEP_SLEEP_GPR_2 = 0x02,
DEEP_SLEEP_GPR_3 = 0x03,
DEEP_SLEEP_GPR_4 = 0x04,
DEEP_SLEEP_GPR_5 = 0x05,
DEEP_SLEEP_GPR_6 = 0x06,
DEEP_SLEEP_GPR_7 = 0x07,
DEEP_SLEEP_GPR_8 = 0x08,
DEEP_SLEEP_GPR_9 = 0x09,
DEEP_SLEEP_GPR_10 = 0x0A,
DEEP_SLEEP_GPR_11 = 0x0B,
DEEP_SLEEP_GPR_12 = 0x0C,
DEEP_SLEEP_GPR_13 = 0x0D,
DEEP_SLEEP_GPR_14 = 0x0E,
DEEP_SLEEP_GPR_15 = 0x0F,
DEEP_SLEEP_GPR_16 = 0x10,
DEEP_SLEEP_GPR_17 = 0x11,
DEEP_SLEEP_GPR_18 = 0x12,
DEEP_SLEEP_GPR_19 = 0x13,
DEEP_SLEEP_GPR_20 = 0x14,
DEEP_SLEEP_GPR_21 = 0x15,
DEEP_SLEEP_GPR_22 = 0x16,
DEEP_SLEEP_GPR_23 = 0x17,
DEEP_SLEEP_GPR_24 = 0x18,
DEEP_SLEEP_GPR_25 = 0x19,
DEEP_SLEEP_GPR_26 = 0x1A,
DEEP_SLEEP_GPR_27 = 0x1B,
DEEP_SLEEP_GPR_28 = 0x1C,
DEEP_SLEEP_GPR_29 = 0x1D,
DEEP_SLEEP_GPR_30 = 0x1E,
DEEP_SLEEP_GPR_31 = 0x1F,
DEEP_SLEEP_GPR_32 = 0x20
} DEEP_SLEEP_GPR;
/* Section 2 - Feature variant inclusion */
#define PLIB_TEMPLATE PLIB_INLINE
#include "../templates/power_PeripheralModuleControl_PIC32_1.h"
#include "../templates/power_VoltageRegulatorControl_Default_1.h"
#include "../templates/power_SleepStatus_Default.h"
#include "../templates/power_IdleStatus_Default.h"
#include "../templates/power_HighVoltageOnVDD1V8_Unsupported.h"
#include "../templates/power_DeepSleepModeOccurrence_Default.h"
#include "../templates/power_HLVDEnableControl_Default.h"
#include "../templates/power_HLVDStopInIdleControl_Default.h"
#include "../templates/power_HLVDStatus_Default.h"
#include "../templates/power_HLVDModeControl_Default.h"
#include "../templates/power_HLVDBandGapVoltageStability_Default.h"
#include "../templates/power_HLVDLimitSelection_Default.h"
#include "../templates/power_DeepSleepModeControl_Default.h"
#include "../templates/power_DeepSleepGPRsRetentionControl_Default.h"
#include "../templates/power_DeepSleepModuleControl_Default.h"
#include "../templates/power_DeepSleepWakeupEventControl_Default.h"
#include "../templates/power_DeepSleepPortPinsStateControl_Default.h"
#include "../templates/power_DeepSleepEventStatus_Default.h"
#include "../templates/power_DeepSleepGPROperation_Default.h"
/* Section 3 - PLIB dispatch function definitions */
PLIB_INLINE_API bool PLIB_POWER_ExistsPeripheralModuleControl(POWER_MODULE_ID index)
{
return POWER_ExistsPeripheralModuleControl_PIC32_1(index);
}
PLIB_INLINE_API void PLIB_POWER_PeripheralModuleDisable(POWER_MODULE_ID index, POWER_MODULE source)
{
POWER_PeripheralModuleDisable_PIC32_1(index, source);
}
PLIB_INLINE_API void PLIB_POWER_PeripheralModuleEnable(POWER_MODULE_ID index, POWER_MODULE source)
{
POWER_PeripheralModuleEnable_PIC32_1(index, source);
}
PLIB_INLINE_API bool PLIB_POWER_PeripheralModuleIsEnabled(POWER_MODULE_ID index, POWER_MODULE source)
{
return POWER_PeripheralModuleIsEnabled_PIC32_1(index, source);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsVoltageRegulatorControl(POWER_MODULE_ID index)
{
return POWER_ExistsVoltageRegulatorControl_Default_1(index);
}
PLIB_INLINE_API void PLIB_POWER_VoltageRegulatorEnable(POWER_MODULE_ID index)
{
POWER_VoltageRegulatorEnable_Default_1(index);
}
PLIB_INLINE_API void PLIB_POWER_VoltageRegulatorDisable(POWER_MODULE_ID index)
{
POWER_VoltageRegulatorDisable_Default_1(index);
}
PLIB_INLINE_API bool PLIB_POWER_VoltageRegulatorIsEnabled(POWER_MODULE_ID index)
{
return POWER_VoltageRegulatorIsEnabled_Default_1(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsSleepStatus(POWER_MODULE_ID index)
{
return POWER_ExistsSleepStatus_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_DeviceWasInSleepMode(POWER_MODULE_ID index)
{
return POWER_DeviceWasInSleepMode_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_ClearSleepStatus(POWER_MODULE_ID index)
{
POWER_ClearSleepStatus_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsIdleStatus(POWER_MODULE_ID index)
{
return POWER_ExistsIdleStatus_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_DeviceWasInIdleMode(POWER_MODULE_ID index)
{
return POWER_DeviceWasInIdleMode_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_ClearIdleStatus(POWER_MODULE_ID index)
{
POWER_ClearIdleStatus_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsHighVoltageOnVDD1V8(POWER_MODULE_ID index)
{
return POWER_ExistsHighVoltageOnVDD1V8_Unsupported(index);
}
PLIB_INLINE_API bool _PLIB_UNSUPPORTED PLIB_POWER_HighVoltageOnVDD1V8HasOccurred(POWER_MODULE_ID index)
{
return POWER_HighVoltageOnVDD1V8HasOccurred_Unsupported(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepModeOccurrence(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepModeOccurrence_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_DeepSleepModeHasOccurred(POWER_MODULE_ID index)
{
return POWER_DeepSleepModeHasOccurred_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepStatusClear(POWER_MODULE_ID index)
{
POWER_DeepSleepStatusClear_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsHLVDEnableControl(POWER_MODULE_ID index)
{
return POWER_ExistsHLVDEnableControl_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_HLVDEnable(POWER_MODULE_ID index)
{
POWER_HLVDEnable_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_HLVDDisable(POWER_MODULE_ID index)
{
POWER_HLVDDisable_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_HLVDIsEnabled(POWER_MODULE_ID index)
{
return POWER_HLVDIsEnabled_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsHLVDStopInIdleControl(POWER_MODULE_ID index)
{
return POWER_ExistsHLVDStopInIdleControl_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_HLVDStopInIdleEnable(POWER_MODULE_ID index)
{
POWER_HLVDStopInIdleEnable_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_HLVDStopInIdleDisable(POWER_MODULE_ID index)
{
POWER_HLVDStopInIdleDisable_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_HLVDStopInIdleIsEnabled(POWER_MODULE_ID index)
{
return POWER_HLVDStopInIdleIsEnabled_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsHLVDStatus(POWER_MODULE_ID index)
{
return POWER_ExistsHLVDStatus_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_HLVDStatusGet(POWER_MODULE_ID index)
{
return POWER_HLVDStatusGet_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsHLVDModeControl(POWER_MODULE_ID index)
{
return POWER_ExistsHLVDModeControl_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_HLVDModeSelect(POWER_MODULE_ID index, HLVD_MODE mode)
{
POWER_HLVDModeSelect_Default(index, mode);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsHLVDBandGapVoltageStability(POWER_MODULE_ID index)
{
return POWER_ExistsHLVDBandGapVoltageStability_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_HLVDBandGapVoltageIsStable(POWER_MODULE_ID index)
{
return POWER_HLVDBandGapVoltageIsStable_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsHLVDLimitSelection(POWER_MODULE_ID index)
{
return POWER_ExistsHLVDLimitSelection_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_HLVDLimitSelect(POWER_MODULE_ID index, HLVD_LIMIT limit)
{
POWER_HLVDLimitSelect_Default(index, limit);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepMode(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepMode_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepModeEnable(POWER_MODULE_ID index)
{
POWER_DeepSleepModeEnable_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepModeDisable(POWER_MODULE_ID index)
{
POWER_DeepSleepModeDisable_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_DeepSleepModeIsEnabled(POWER_MODULE_ID index)
{
return POWER_DeepSleepModeIsEnabled_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepGPRsRetentionControl(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepGPRsRetentionControl_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepGPRsRetentionEnable(POWER_MODULE_ID index)
{
POWER_DeepSleepGPRsRetentionEnable_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepGPRsRetentionDisable(POWER_MODULE_ID index)
{
POWER_DeepSleepGPRsRetentionDisable_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepModuleControl(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepModuleControl_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepModuleEnable(POWER_MODULE_ID index, DEEP_SLEEP_MODULE module)
{
POWER_DeepSleepModuleEnable_Default(index, module);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepModuleDisable(POWER_MODULE_ID index, DEEP_SLEEP_MODULE module)
{
POWER_DeepSleepModuleDisable_Default(index, module);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepWakeupEventControl(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepWakeupEventControl_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepWakeupEventEnable(POWER_MODULE_ID index, DEEP_SLEEP_WAKE_UP_EVENT event)
{
POWER_DeepSleepWakeupEventEnable_Default(index, event);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepWakeupEventDisable(POWER_MODULE_ID index, DEEP_SLEEP_WAKE_UP_EVENT event)
{
POWER_DeepSleepWakeupEventDisable_Default(index, event);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepPortPinsStateControl(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepPortPinsStateControl_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepPortPinsStateRetain(POWER_MODULE_ID index)
{
POWER_DeepSleepPortPinsStateRetain_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepPortPinsStateRelease(POWER_MODULE_ID index)
{
POWER_DeepSleepPortPinsStateRelease_Default(index);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepEventStatus(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepEventStatus_Default(index);
}
PLIB_INLINE_API DEEP_SLEEP_EVENT PLIB_POWER_DeepSleepEventStatusGet(POWER_MODULE_ID index)
{
return POWER_DeepSleepEventStatusGet_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepEventStatusClear(POWER_MODULE_ID index, DEEP_SLEEP_EVENT event)
{
POWER_DeepSleepEventStatusClear_Default(index, event);
}
PLIB_INLINE_API bool PLIB_POWER_ExistsDeepSleepGPROperation(POWER_MODULE_ID index)
{
return POWER_ExistsDeepSleepGPROperation_Default(index);
}
PLIB_INLINE_API void PLIB_POWER_DeepSleepGPRWrite(POWER_MODULE_ID index, DEEP_SLEEP_GPR gpr, uint32_t data)
{
POWER_DeepSleepGPRWrite_Default(index, gpr, data);
}
PLIB_INLINE_API uint32_t PLIB_POWER_DeepSleepGPRRead(POWER_MODULE_ID index, DEEP_SLEEP_GPR gpr)
{
return POWER_DeepSleepGPRRead_Default(index, gpr);
}
#endif
| [
"gustmuro@gmail.com"
] | gustmuro@gmail.com |
9183ac4a156d2f3c972a2b3b78c50cdd8eb6ea79 | cf36d676fb7d1266d6b4447e9dd20b95e603f1c5 | /lab6/BinaryConvertor.c | 2ca3bff91b0ffbef1391fa51a5cf37293bac4ed9 | [] | no_license | Thawatchai-Yango/Data_Structure_with_C | ceff1dc04ae613d4bcf652042d75ee73950887e5 | d672e7b5546227cd29298ab63667b775084f67a8 | refs/heads/main | 2023-08-11T10:06:11.318093 | 2021-09-19T13:30:08 | 2021-09-19T13:30:08 | 408,133,518 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 2,293 | c | #include <stdio.h>
#include <stdlib.h>
int main()
{
char num1,num2,num3,num4,num5,num6,num7,num8,hex11,hex12;
int b0 = 0,b1 = 0,b2 = 0,b3 = 0,b4 = 0,b5 = 0,b6 = 0,b7 = 0;
int ch,Decimal,Octal,Octal2,Octal3,hex1,hex2;
printf("1. Convert Binary to Decimal\n");
printf("2. Convert Binary to Octal\n");
printf("3. Convert Binary to Hexadecimal\n");
printf("4. Exit\n");
printf("Choose a choice: ");
scanf("%d",&ch);
if(ch==4)
{
printf("Exit completed..\n\n");
exit(EXIT_SUCCESS);
}
else if (ch > 4)
{
printf("not valid option!\n\n");
exit(EXIT_SUCCESS);
}
printf("Input Binary number (8 digits) : ");
scanf(" %c%c%c%c%c%c%c%c",&num1,&num2,&num3,&num4,&num5,&num6,&num7,&num8);
b0 = num1-48;
b1 = num2-48;
b2 = num3-48;
b3 = num4-48;
b4 = num5-48;
b5 = num6-48;
b6 = num7-48;
b7 = num8-48;
if( (b0==1 || b0==0) && (b1==1 || b1==0) && (b2==1 || b2==0) && (b3==1 || b3==0)
&& (b4==1 || b4==0) && (b5==1 || b5==0) && (b6==1 || b6==0) && (b7==1 || b7==0) )
{
printf("Binary Number is %c%c%c%c%c%c%c%c\n",num1,num2,num3,num4,num5,num6,num7,num8);
}
else
{
printf("Error! digit must be 1 or 0\n");
exit(EXIT_SUCCESS);
}
if(ch==1)
{
Decimal = b0*128 + b1*64 + b2*32 + b3*16 + b4*8 + b5*4 + b6*2 + b7*1;
printf("Decimal is %d\n", Decimal);
}
else if(ch==2)
{
Octal = b0*2 + b1*1;
Octal2 = b2*4 + b3*2 + b4*1;
Octal3 = b5*4 + b6*2 + b7*1;
printf("Octal is %d%d%d\n", Octal,Octal2,Octal3);
}
else if(ch==3)
{
if(b0<=1 && b1<=1 && b2<=1 && b3<=1 && b4<=1 && b5<=1 && b6<=1 && b7<=1)
{
hex1 = (b0*8)+(b1*4)+(b2*2)+(b3*1);
hex2 = (b4*8)+(b5*4)+(b6*2)+(b7*1);
if(hex1<=9)
hex11 = hex1+48;
if(hex2<=9)
hex12 = hex2+48;
if(hex1>9)
hex11 = hex1+55;
if(hex2>9)
hex12 = hex2+55;
}
printf("Hexadecimal is %c%c\n",hex11,hex12);
}
return 0;
}
| [
"noreply@github.com"
] | Thawatchai-Yango.noreply@github.com |
8ec0923b8e2edb21c80dc0d410740cf11dd32bc0 | bf332bd0e4470608c0a187fba5f21e20c9d263fe | /PipeGen4/Backend/MuxAlloc.c | 6597577d2a4ca42d451bc257a745eef09fa32359 | [] | no_license | jinz2014/FP_HLS | db41b22c333ee8579708dff4ee3ff3dd959c3bdf | cbf30212f05b9bdfa67545faeb95689bf6b4d669 | refs/heads/master | 2020-05-30T19:06:20.640459 | 2015-05-13T19:28:43 | 2015-05-13T19:28:43 | 35,570,680 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 35,193 | c | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "Schedule.h"
//-------------------------------------------------------------------------
// Interconnection allocation main function
//-------------------------------------------------------------------------
int InterconnectionAlloc (int *Map, int SharedRegNu) {
int i, j, k;
int ri, rj;
int dest0, dest1;
int flag0, flag1;
int offset;
int fu_nu, port_nu;
enum operation op_type;
MuxPtr nextMux;
MuxPtr Mux;
int MuxCnt = 0;
int MuxInputNu;
int p0, p1, p;
CreateMuxRAT();
//---------------------------------------------------------
//
//---------------------------------------------------------
CreateFuRAT(Map, SharedRegNu);
//---------------------------------------------------------
// Find the register pair that is connected to the same FU
//
// Map[ri] != Map[rj] && Map[ri] && Map[rj]
//
// case 1: the register pair are mapped to different shared registers.
// case 2: the register pair are mapped to the same shared register.
//---------------------------------------------------------
// ri and rj represent operation output variables
for (ri = 0; ri < NODE_NU; ri++) {
for (rj = ri + 1; rj < NODE_NU; rj++) {
for (i = 0; i < DFG[ri]->opDestNu; i++) {
// More than one destination
dest0 = DFG[ri]->opDest[i];
for (j = 0; j < DFG[rj]->opDestNu; j++) {
dest1 = DFG[rj]->opDest[j];
//---------------------------------------------------------
// The register pair is connected to the same FU and
// they are mapped to two different shared registers
// Note ri != rj
//---------------------------------------------------------
if (dest0 > 0 && dest1 > 0 &&
Map[ri] != Map[rj] &&
Map[ri] && Map[rj] &&
DFG[dest0]->opResourceNu == DFG[dest1]->opResourceNu &&
DFG[dest0]->op == DFG[dest1]->op) { // same floating precision implied
//---------------------------------------------------------
// Check if the register pair has a common FU port after
// they are mapped to the same FU.
//---------------------------------------------------------
p0 = GetNodeSrcNu(DFG[dest0]->op);
p1 = GetNodeSrcNu(DFG[dest1]->op);
assert(p0 == p1);
p = p0;
for (port_nu = 0; port_nu < p; port_nu++) {
if (DFG[dest0]->opSrc[port_nu] == ri &&
DFG[dest1]->opSrc[port_nu] == rj) {
// operation type
op_type = DFG[dest0]->op;
// FU number
offset = 0;
fu_nu = DFG[dest0]->opResourceNu - offset - 1;
//-----------------------------------------------------------------------
// 6/23/11
//
// MUX input constant optimizations
//
// 1. Allocate no mux if two inputs have the same constant
// 2. Check if there are redundant Mux input constants even if the
// the constant values are different. Because the same MUX may have
// already been allocated. We assume that mux data field
// (Mux->Mi->constNu) contains nonzero value(s) if the mux
// input is a constant. Otherwise it is 0.
//
// 8/1/11
//
// 3. FMUX32 or FMUX64 input constants check are ignored.
//-----------------------------------------------------------------------
if (port_nu == 1 && DFG[dest0]->opConst && DFG[dest1]->opConst) {
if (DFG[dest0]->opConstVal == DFG[dest1]->opConstVal) {
myprintf("P1: node %d and %d have the same constant values %f\n", \
dest0, dest1, DFG[dest0]->opConstVal);
continue;
}
else {
flag0 = flag1 = 0;
myprintf("P1: For type = %s fu_nu = %d ",opSymTable(op_type), fu_nu);
myprintf("check any redundant mux input constant values\n");
Mux = (MuxRAT[op_type][fu_nu]).Fu_portNu[port_nu];
while (Mux != NULL) {
for (k = 0; k < 2; k++) {
//-------------------------------------------------------------
//-------------------------------------------------------------
if (DFG[dest0]->opPrecision == sfp) {
if (DFG[dest0]->opConstVal == *(Mux->Mi->constNu + k))
flag0 = 1;
if (DFG[dest1]->opConstVal == *(Mux->Mi->constNu + k))
flag1 = 1;
}
//-------------------------------------------------------------
//-------------------------------------------------------------
if (DFG[dest0]->opPrecision == dfp) {
if (DFG[dest0]->opConstVal_d == *(Mux->Mi->constNu_d + k))
flag0 = 1;
if (DFG[dest1]->opConstVal_d == *(Mux->Mi->constNu_d + k))
flag1 = 1;
}
}
Mux = Mux->next;
}
}
if (flag0 && flag1) continue; // redundant mux when both flags are set!
}
myprintf("P1: Common port number %d for node %d and %d sharing %s\n", \
port_nu, dest0, dest1, opSymTable(op_type));
// Check Mux allocation and allocate a Mux if it is not allocated.
myprintf("CheckMuxAlloc...\n");
nextMux = CheckMuxAlloc(Map, op_type, fu_nu, port_nu, ri, rj,
i, j, 0, &MuxCnt);
// Insert the allocated Mux into Mux list
myprintf("MuxListInsert...\n");
MuxListInsert(op_type, fu_nu, port_nu, nextMux);
myprintf("\n");
}
}
}
}
}
}
}
//=====================================================================================
//
// Allocate FU port ONE's MUX
//
// FU port ONE may contain constants
//
// It deals with two cases when Map[ri] == Map[rj] && Map[ri] && Map[rj]
// 1. both inputs are constants
// 2. only one input is a constant
//=====================================================================================
for (ri = 0; ri < NODE_NU; ri++) {
for (rj = ri; rj < NODE_NU; rj++) {
for (i = 0; i < DFG[ri]->opDestNu; i++) {
//----------------------------------------------------------
// Including multiple destinations, but some nodes will be
// visited several times.
//----------------------------------------------------------
dest0 = DFG[ri]->opDest[i];
for (j = 0; j < DFG[rj]->opDestNu; j++) {
dest1 = DFG[rj]->opDest[j];
//---------------------------------------------------------
// The register pair is connected to the same FU and
// they're mapped to the same shared register. So
// Mux is not allocated on FU port 0.
// But Mux may be allocated on FU port 1.
//---------------------------------------------------------
if (dest0 > 0 && dest1 > 0 &&
Map[ri] == Map[rj] && Map[ri] && Map[rj] &&
DFG[dest0]->opResourceNu == DFG[dest1]->opResourceNu &&
DFG[dest0]->op == DFG[dest1]->op) { // same floating precision implied
//-------------------------------------------------------------
// Here mux is not needed at a shared FU's input port
// because two inputs to the FU are mapped to the same register.
//-------------------------------------------------------------
// operation type
op_type = DFG[dest0]->op;
// FU number
offset = 0;
fu_nu = DFG[dest0]->opResourceNu - offset - 1;
// Constant reduction (the if condition also implies that we are looking at FU
// port ONE
if (DFG[dest0]->opConst && DFG[dest1]->opConst) {
if (DFG[dest0]->opPrecision == sfp && DFG[dest1]->opPrecision == sfp &&
DFG[dest0]->opConstVal == DFG[dest1]->opConstVal) {
myprintf("P2: node %d and %d have the same single constant values %f\n", \
dest0, dest1, DFG[dest0]->opConstVal);
continue;
}
else if (DFG[dest0]->opPrecision == dfp && DFG[dest1]->opPrecision == dfp &&
DFG[dest0]->opConstVal_d == DFG[dest1]->opConstVal_d) {
myprintf("P2: node %d and %d have the same double constant values %f\n", \
dest0, dest1, DFG[dest0]->opConstVal_d);
continue;
}
else {
flag0 = flag1 = 0;
myprintf("P2: For type = %s fu_nu = %d ",opSymTable(op_type), fu_nu);
myprintf("check any redundant mux input constant values\n");
Mux = (MuxRAT[op_type][fu_nu]).Fu_portNu[1];
while (Mux != NULL) {
for (k = 0; k < 2; k++) {
//-------------------------------------------------------------
//-------------------------------------------------------------
if (DFG[dest0]->opPrecision == sfp) {
if (DFG[dest0]->opConstVal == *(Mux->Mi->constNu + k))
flag0 = 1;
if (DFG[dest1]->opConstVal == *(Mux->Mi->constNu + k))
flag1 = 1;
}
//-------------------------------------------------------------
//-------------------------------------------------------------
if (DFG[dest0]->opPrecision == dfp) {
if (DFG[dest0]->opConstVal_d == *(Mux->Mi->constNu_d + k))
flag0 = 1;
if (DFG[dest1]->opConstVal_d == *(Mux->Mi->constNu_d + k))
flag1 = 1;
}
}
Mux = Mux->next;
}
}
if (flag0 && flag1)
continue;
else
port_nu = 1;
} else if (
(DFG[dest0]->opConst && DFG[dest1]->opSrc[1] == rj) ||
(DFG[dest0]->opSrc[1] == ri && DFG[dest1]->opConst)) {
port_nu = 1;
}
else
continue;
//-----------------------------------------------------------
// 6/29/11
// Map[ri] == Map[rj] means:
// 1) ri == rj
// 2) ri != rj and Map[ri] == Map[rj]
//
// Note on case 1:
// A node's multiple destinatins may require a mux for their
// input ports. In the example below, the two "*" operations
// are shared by a multiplier, then
//
// 3.0 4.0
// D 3.0 D 4.0 \/
// \ / \ / ====> D mux
// (*) (*) \ /
// (*)
//
// Here ri(rj) is the node D's id.
// If the loop variable rj is set to ri + 1 in the for loop,
// then this mux cannot be generated because node's src[1] equals
// src[0] when src[1] is a constant
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// for (ri = 0; ri < NODE_NU; ri++) {
// for (rj = ri; rj < NODE_NU; rj++) {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Map[ri] != Map[rj] ==> ri != rj
// So no problem when rj is set to ri + 1 in the for loop.
//-----------------------------------------------------------
if (ri == rj)
myprintf("P2: Mux inputs come from the same register\n");
else
myprintf("P2: Mux inputs come from different registers\n");
myprintf("P2: Common port number %d for node %d and %d sharing %s\n", \
port_nu, dest0, dest1, opSymTable(op_type));
// Check Mux allocation and allocate a Mux appropriately
myprintf("CheckMuxAlloc...\n");
nextMux = CheckMuxAlloc(Map, op_type, fu_nu, port_nu, ri, rj,
i, j, 1, &MuxCnt);
// Insert the Mux into Mux list
myprintf("MuxListInsert...\n");
MuxListInsert(op_type, fu_nu, port_nu, nextMux);
}
}
}
}
}
MuxRATPrint();
//MuxInputNu = GenerateHDL(Map, SharedRegNu, ScheduleName);
return MuxCnt;
}
void FreeTables(int SharedRegNu) {
FreeMuxRAT();
FreeFuRAT(SharedRegNu);
FreeVarTable(SharedRegNu);
}
//----------------------------------------------------------------
//
//----------------------------------------------------------------
MuxPtr CheckMuxAlloc(int *Map, int op_type, int fu_nu, int port_nu,
int ri, int rj, int di, int dj,
int constFlag, int *MuxCnt) {
MuxPtr head, Mux;
myprintf("op_type = %s fu_nu = %d port_nu = %d ri = %d(Map = %d) rj = %d(Map = %d)\n",
opSymTable(op_type), fu_nu, port_nu,
ri, Map[ri], rj, Map[rj]);
head = (MuxRAT[op_type][fu_nu]).Fu_portNu[port_nu];
Mux = CheckMuxList(Map, head, ri, rj, di, dj,
fu_nu, port_nu, constFlag, MuxCnt);
return Mux;
}
//-------------------------------------------------------------------
// The head pointer implies that the register pair has a common FU
//-------------------------------------------------------------------
MuxPtr CheckMuxList(int *Map, MuxPtr head, int ri, int rj, int di, int dj,
int fu_nu, int port_nu, int constFlag, int *MuxCnt) {
//!
// 4/7/2012 initialization because
// if (DFG[DFG[ri]->opDest[di]]->opPrecision == sfp or dfp)
//!
float mux_i_c1 = 0, mux_i_c2 = 0;
double mux_i_c1_d = 0, mux_i_c2_d = 0;
int mux_i_r1, mux_i_r2,
mux_i_d1, mux_i_d2,
mux_i_m1, mux_i_m2,
mux_i_f1, mux_i_f2;
int mux_o_r, mux_o_m, mux_o_fu;
int Ri, Rj;
int Di, Dj;
int ri_SharedFlag, rj_SharedFlag;
MuxPtr p;
MuxPtr parentMux = NULL;
int *currRegNu;
float *currConstNu;
double *currConstNu_d;
//---------------------------------------------------------------
// Assume a constant value of zero mustn't exist in the DFG
//---------------------------------------------------------------
// physical FU's logical source numbers
Ri = ri;
Rj = rj;
//Ri = (mux_i_c1 == 0) ri : -1;
//Rj = (mux_i_c2 == 0) rj : -1;
// physical FU's logical destination number
// corresponding to logical source numbers
Di = DFG[ri]->opDest[di];
Dj = DFG[rj]->opDest[dj];
// if the operation (ri, di) in DFG(not shared FU) has a constant input
if (DFG[Di]->opPrecision == sfp) {
mux_i_c1 = (port_nu == 1 && DFG[Di]->opConst) ? DFG[Di]->opConstVal : 0;
assert (DFG[Dj]->opPrecision == sfp);
}
if (DFG[Di]->opPrecision == dfp) {
mux_i_c1_d = (port_nu == 1 && DFG[Di]->opConst) ? DFG[Di]->opConstVal_d : 0;
assert (DFG[Dj]->opPrecision == dfp);
}
// if the operation (rj, dj) in DFG(not shared FU) has a constant input
if (DFG[Dj]->opPrecision == sfp) {
mux_i_c2 = (port_nu == 1 && DFG[Dj]->opConst) ? DFG[Dj]->opConstVal : 0;
assert (DFG[Dj]->opPrecision == sfp);
}
if (DFG[Dj]->opPrecision == dfp) {
mux_i_c2_d = (port_nu == 1 && DFG[Dj]->opConst) ? DFG[Dj]->opConstVal_d : 0;
}
// There is no Mux and allocate a Mux.
if (head == NULL) {
mux_i_r1 = Ri;
mux_i_r2 = Rj;
mux_i_d1 = Di;
mux_i_d2 = Dj;
mux_i_m1 = -1;
mux_i_m2 = -1;
mux_i_f1 = -1;
mux_i_f2 = -1;
mux_o_r = -1;
mux_o_m = -1;
mux_o_fu = fu_nu;
}
else {
p = head;
ri_SharedFlag = 0;
rj_SharedFlag = 0;
// check how to allocate the mux by comparing it with all the
// allocated muxes.
while (p != NULL) {
currRegNu = p->Mi->regNu;
currConstNu = p->Mi->constNu;
currConstNu_d = p->Mi->constNu_d;
if (constFlag) {
if (currRegNu[0] == ri || currRegNu[1] == ri)
ri_SharedFlag = 1;
if (currRegNu[0] == rj || currRegNu[1] == rj)
rj_SharedFlag = 1;
}
else {
//------------------------------------------------------------------
// if the constant value is the same as any constant of an
// allocated mux's left or right input, then a chained mux will
// be generated later
//------------------------------------------------------------------
if (DFG[DFG[ri]->opDest[di]]->opPrecision == sfp) {
if (mux_i_c1 && mux_i_c2) {
if (mux_i_c1 == currConstNu[0] || mux_i_c1 == currConstNu[1])
ri_SharedFlag = 1;
if (mux_i_c2 == currConstNu[0] || mux_i_c2 == currConstNu[1])
rj_SharedFlag = 1;
} else if (mux_i_c1) {
if (mux_i_c1 == currConstNu[0] || mux_i_c1 == currConstNu[1])
ri_SharedFlag = 1;
// make sure the mux input rj connects a register, not a constant
if (Map[currRegNu[0]] == Map[rj] && currConstNu[0] == 0 ||
Map[currRegNu[1]] == Map[rj] && currConstNu[1] == 0)
rj_SharedFlag = 1;
} else if (mux_i_c2) {
// make sure the mux input ri connects a register, not a constant
if (Map[currRegNu[0]] == Map[ri] && currConstNu[0] == 0 ||
Map[currRegNu[1]] == Map[ri] && currConstNu[1] == 0)
ri_SharedFlag = 1;
if (mux_i_c2 == currConstNu[0] || mux_i_c2 == currConstNu[1])
rj_SharedFlag = 1;
} else {
if (Map[currRegNu[0]] == Map[ri] || Map[currRegNu[1]] == Map[ri])
ri_SharedFlag = 1;
if (Map[currRegNu[0]] == Map[rj] || Map[currRegNu[1]] == Map[rj])
rj_SharedFlag = 1;
}
}
if (DFG[DFG[ri]->opDest[di]]->opPrecision == dfp) {
if (mux_i_c1_d && mux_i_c2_d) {
if (mux_i_c1_d == currConstNu_d[0] || mux_i_c1_d == currConstNu_d[1])
ri_SharedFlag = 1;
if (mux_i_c2_d == currConstNu_d[0] || mux_i_c2_d == currConstNu_d[1])
rj_SharedFlag = 1;
} else if (mux_i_c1_d) {
if (mux_i_c1_d == currConstNu_d[0] || mux_i_c1_d == currConstNu_d[1])
ri_SharedFlag = 1;
// make sure the mux input connects a register, not a constant
if (Map[currRegNu[0]] == Map[rj] && currConstNu_d[0] == 0 ||
Map[currRegNu[1]] == Map[rj] && currConstNu_d[1] == 0)
rj_SharedFlag = 1;
} else if (mux_i_c2_d) {
// make sure the mux input connects a register, not a constant
if (Map[currRegNu[0]] == Map[ri] && currConstNu_d[0] == 0 ||
Map[currRegNu[1]] == Map[ri] && currConstNu_d[1] == 0)
ri_SharedFlag = 1;
if (mux_i_c2_d == currConstNu_d[0] || mux_i_c2_d == currConstNu_d[1])
rj_SharedFlag = 1;
} else {
if (Map[currRegNu[0]] == Map[ri] || Map[currRegNu[1]] == Map[ri])
ri_SharedFlag = 1;
if (Map[currRegNu[0]] == Map[rj] || Map[currRegNu[1]] == Map[rj])
rj_SharedFlag = 1;
}
}
}
p = p->next;
}
p = head;
// Same Mux inputs with no allocation needed
if (ri_SharedFlag && rj_SharedFlag) {
return NULL;
}
else if (ri_SharedFlag) { // rj_SharedFlag = 0 is implied
// Get new mux port 1 input source in a chained muxs
parentMux = GetMuxID(p);
mux_i_r1 = Ri;
mux_i_r2 = Rj;
mux_i_d1 = Di;
mux_i_d2 = Dj;
mux_i_m1 = parentMux->m;
mux_i_m2 = -1;
mux_i_f1 = -1;
mux_i_f2 = -1;
mux_o_r = -1;
mux_o_m = -1;
mux_o_fu = fu_nu;
}
else if (rj_SharedFlag) {
// Get new mux port 2 input source in a chained muxs
parentMux = GetMuxID(p);
mux_i_r1 = Ri;
mux_i_r2 = Rj;
mux_i_d1 = Di;
mux_i_d2 = Dj;
mux_i_m1 = -1;
mux_i_m2 = parentMux->m;
mux_i_f1 = -1;
mux_i_f2 = -1;
mux_o_r = -1;
mux_o_m = -1;
mux_o_fu = fu_nu;
}
else {
mux_i_r1 = Ri;
mux_i_r2 = Rj;
mux_i_d1 = Di;
mux_i_d2 = Dj;
mux_i_m1 = -1;
mux_i_m2 = -1;
mux_i_f1 = -1;
mux_i_f2 = -1;
mux_o_r = -1;
mux_o_m = -1;
mux_o_fu = fu_nu;
}
}
return MuxAlloc(Map, parentMux,
mux_i_r1, mux_i_r2,
mux_i_d1, mux_i_d2,
mux_i_c1, mux_i_c2,
mux_i_c1_d, mux_i_c2_d,
mux_i_m1, mux_i_m2,
mux_i_f1, mux_i_f2,
mux_o_r, mux_o_m,
mux_o_fu, MuxCnt);
}
//-------------------------------------------------------------------------
//
//-------------------------------------------------------------------------
void MuxListInsert(int op_type, int fu_nu, int port_nu, MuxPtr nextMux) {
MuxPtr p0, p1;
MuxPtr head;
// No Mux allocated
if (nextMux == NULL) return;
p0 = head = (MuxRAT[op_type][fu_nu]).Fu_portNu[port_nu];
if (head == NULL) {
head = nextMux;
myprintf("Create head Mux ID %d \n", nextMux->m);
//nextMux->next = NULL;
} else {
while (p0 != NULL) {
p1 = p0;
p0 = p0->next;
}
// Append the Mux at the end of the list
myprintf("Append Mux ID %d \n", nextMux->m);
p1->next = nextMux;
nextMux->next = NULL;
}
(MuxRAT[op_type][fu_nu]).Fu_portNu[port_nu] = head;
}
void MuxRATPrint() {
enum operation op_type;
int fu_nu, port_nu;
int portNu;
MuxPtr Mux, head;
int i;
int size;
myprintf("------------ MuxRAT ---------------------------\n");
for (op_type = add; op_type < add + OP_NU; op_type++) {
size = (*RQ[op_type])->size;
for (fu_nu = 0; fu_nu < size; fu_nu++) {
portNu = GetNodeSrcNu(op_type);
for (port_nu = 0; port_nu < portNu; port_nu++) {
Mux = (MuxRAT[op_type][fu_nu]).Fu_portNu[port_nu];
while (Mux != NULL) {
myprintf("MuxRAT: op = %3d fu_nu = %3d port_nu = %3d\n",
op_type, fu_nu, port_nu);
myprintf("Mux number: %d\n", Mux->m);
myprintf("Mux partition group number: %d\n", Mux->grp);
myprintf("i SP Constant Number: ");
for (i = 0; i < 2; i++) myprintf("%f ", *(Mux->Mi->constNu + i));
myprintf("i DP Constant Number: ");
for (i = 0; i < 2; i++) myprintf("%f ", *(Mux->Mi->constNu_d + i));
myprintf("\ni Register Number: ");
for (i = 0; i < 2; i++) myprintf("%d ", *(Mux->Mi->regNu + i));
myprintf("\ni Destination Number: ");
for (i = 0; i < 2; i++) myprintf("%d ", *(Mux->Mi->destNu + i));
myprintf("\ni Mux Number: ");
for (i = 0; i < 2; i++) myprintf("%d ", *(Mux->Mi->muxNu + i));
myprintf("\ni Fu Number: ");
for (i = 0; i < 2; i++) myprintf("%d ", *(Mux->Mi->fuNu + i));
myprintf("\no Mux Number: ");
myprintf("%d ", *(Mux->Mo->muxNu));
myprintf("\no Fu Number: ");
myprintf("%d ", *(Mux->Mo->fuNu));
myprintf("\n\n");
Mux = Mux->next;
}
}
}
}
}
//-------------------------------------------------------------------
// If the input port of the newly allocated Mux is the same
// as that of any Mux in the Mux list, find the last Mux output port
// that the input port of the new Mux can be connected to.
//
// Return: the MuxID of the last Mux which meets the above requirement
// is returned.
//-------------------------------------------------------------------
MuxPtr GetMuxID(MuxPtr head) {
MuxPtr p, parentMux;
p = head;
while (p != NULL) {
if (*(p->Mo->muxNu) == -1) {
assert(*(p->Mo->fuNu) != -1);
*(p->Mo->fuNu) = -1;
break;
}
p = p->next;
}
return (p);
}
//--------------------------------------------------------------------------
// For each shared register, find the set of FU that
// write the result into the register.
//--------------------------------------------------------------------------
ResourceList ResourceListInsert(ResourceList head, enum operation op, int resourceNu) {
ResourceList resource;
ResourceList p0, p1, p2;
p0 = p2 = head;
/* Check resource op and number are unique */
while (p2 != NULL) {
// +1/5/11
// Add port nodes only when they are mapped to different physical ports
if (op == nop && GetInputPortNu(p2->nu) == GetInputPortNu(resourceNu) ||
p2->nu == resourceNu && p2->op == op)
// -1/5/11
//if (p2->nu == resourceNu && p2->op == op)
return head;
else
p2 = p2->next;
}
resource = malloc(sizeof(struct Resource));
resource->op = op;
resource->nu = resourceNu;
if (head == NULL) {
//myprintf("Empty: Inserting resource type %d nu %d \n", op, resourceNu);
head = resource;
resource->next = NULL;
} else {
while (p0 != NULL) {
p1 = p0;
p0 = p0->next;
}
//myprintf("Append: Inserting resource type %d nu %d \n", op, resourceNu);
p1->next = resource;
resource->next = NULL;
}
return (head);
}
void ResourceListPrint(ResourceList head) {
ResourceList p = head;
while (p != NULL) {
myprintf("--- op = %s nu = %3d\n", opSymTable(p->op), p->nu);
p = p->next;
}
}
//-------------------------------------------------
// The structure of the FuRAT:
//
// sr: shared register
// Fu: Fu number and operation
//
// +---+
// +sr0+ not used
// +---+ +---+
// +sr1+ --- +Fu + -- Resource Lists
// +---+ +---+
// +sr2+ ..... ............
// +---+
// +sr3+ ..... ............
// +---+
//-------------------------------------------------
void CreateFuRAT(int *Map, int SharedRegNu) {
enum operation op_type;
int resourceNu;
int regNu;
int i;
FuRAT = (ResourceList *) malloc (sizeof(ResourceList) * (SharedRegNu + 1));
for (i = 0; i <= SharedRegNu; i++) FuRAT[i] = NULL;
for (regNu = 1; regNu <= SharedRegNu; regNu++) {
for (i = 0; i < NODE_NU; i++) {
if (regNu == Map[i]) {
op_type = DFG[i]->op;
resourceNu = DFG[i]->opResourceNu;
FuRAT[regNu] = ResourceListInsert(FuRAT[regNu], op_type, resourceNu);
}
}
}
for (i = 1; i <= SharedRegNu; i++) {
myprintf("Shared register %d resource list:\n", i);
ResourceListPrint(FuRAT[i]);
}
}
//-------------------------------------------------
// The structure of the MuxRAT:
//
// op: non-port FU operation type
// f: FU number
// p: FU's port number
//
// op0 +---+
// +---+ +p0 + -- Mux Lists
// +f0 + +---+
// + + ---
// + + +---+
// + + +p1 + -- Mux Lists
// +---+ +---+
// +f1 + ..... ............
// + + ---
// + + ..... ............
// +---+
// +f2 + ..... ............
// + + ---
// + + ..... ............
// +---+
//
// op1 +---+
// +---+ +p0 + -- Mux Lists
// +f0 + +---+
// + + ---
// + + +---+
// + + +p1 + -- Mux Lists
// +---+ +---+
// +f1 + ..... ............
// + + ---
// + + ..... ............
// +---+
// +f2 + ..... ............
// + + ---
// + + ..... ............
// +---+
//
// .... ... .... ............
// .... ... .... ............
//-------------------------------------------------
void CreateMuxRAT() {
int size;
int fu_nu, port_nu;
int portNu;
enum operation op_type;
MuxRAT = (Fu**) malloc (sizeof(Fu*) * OP_NU);
for (op_type = add; op_type < add + OP_NU; op_type++) {
// Number of non-port FUs
size = (*RQ[op_type])->size;
MuxRAT[op_type] = (Fu*) malloc (sizeof(Fu) * size);
for (fu_nu = 0; fu_nu < size; fu_nu++) {
// 7/30/11
portNu = GetNodeSrcNu(op_type);
// Two input ports of each FU
(MuxRAT[op_type][fu_nu]).Fu_portNu =
(MuxPtr *) malloc (sizeof(MuxPtr) * portNu);
//
for (port_nu = 0; port_nu < portNu; port_nu++)
(MuxRAT[op_type][fu_nu]).Fu_portNu[port_nu] = NULL;
}
}
}
//-------------------------------------------------
// Allocate a new Mux and configure its i/o ports
//-------------------------------------------------
MuxPtr MuxAlloc(int *Map, MuxPtr parentMux,
int mux_i_r1, int mux_i_r2,
int mux_i_d1, int mux_i_d2,
float mux_i_c1, float mux_i_c2,
double mux_i_c1_d, double mux_i_c2_d,
int mux_i_m1, int mux_i_m2,
int mux_i_f1, int mux_i_f2,
int mux_o_r, int mux_o_m,
int mux_o_fu, int *MuxCnt) {
float *constNu;
double *constNu_d;
int *destNu, *regNu, *muxNu, *fuNu;
MuxPtr MP;
(*MuxCnt)++;
// Allocate a Mux between register pairs and FU
MP = (MuxPtr) malloc (sizeof(struct Mux));
MP->Mi = (MiPtr) malloc (sizeof(MuxInputs));
MP->Mo = (MoPtr) malloc (sizeof(MuxOutputs));
MP->m = *MuxCnt;
MP->grp = 1; // 1 group by default
MP->next = NULL;
MP->Mi->constNu = (float *) malloc (2 * sizeof(float));
MP->Mi->constNu_d = (double *) malloc (2 * sizeof(double));
MP->Mi->destNu = (int *) malloc (2 * sizeof(int));
MP->Mi->regNu = (int *) malloc (2 * sizeof(int));
MP->Mi->muxNu = (int *) malloc (2 * sizeof(int));
MP->Mi->fuNu = (int *) malloc (2 * sizeof(int));
MP->Mo->regNu = (int *) malloc (sizeof(int));
MP->Mo->muxNu = (int *) malloc (sizeof(int));
MP->Mo->fuNu = (int *) malloc (sizeof(int));
constNu = MP->Mi->constNu;
constNu[0] = mux_i_c1;
constNu[1] = mux_i_c2;
constNu_d = MP->Mi->constNu_d;
constNu_d[0] = mux_i_c1_d;
constNu_d[1] = mux_i_c2_d;
regNu = MP->Mi->regNu;
regNu[0] = mux_i_r1;
regNu[1] = mux_i_r2;
destNu = MP->Mi->destNu;
destNu[0] = mux_i_d1;
destNu[1] = mux_i_d2;
muxNu = MP->Mi->muxNu;
muxNu[0] = mux_i_m1;
muxNu[1] = mux_i_m2;
fuNu = MP->Mi->fuNu;
fuNu[0] = mux_i_f1;
fuNu[1] = mux_i_f2;
*(MP->Mo->fuNu) = mux_o_fu;
*(MP->Mo->regNu) = mux_o_r;
*(MP->Mo->muxNu) = mux_o_m;
// Change parent Mux output destination
// to the current Mux ID number MuxCnt
if (parentMux != NULL)
*(parentMux->Mo->muxNu) = *MuxCnt;
return MP;
}
void FreeFuRAT (int SharedRegNu) {
int regNu;
ResourceList head, p, p1, p2;
// Free Fu list
for (regNu = 1; regNu <= SharedRegNu; regNu++) {
p = head = FuRAT[regNu];
// For each loop, go to the last node and delete it
while (p != NULL) {
p2 = p;
p1 = p->next;
if (p1 != NULL) {
while (p1->next != NULL) {
p2 = p1;
p1 = p1->next;
}
p2->next = p1->next;
free(p1);
p = head;
} else {
free(p);
break;
}
}
}
free(FuRAT);
}
void FreeMuxList() {
enum operation op_type;
int fu_nu, port_nu;
int portNu;
int size;
MuxPtr head, p, p1, p2;
for (op_type = add; op_type < add + OP_NU; op_type++) {
size = (*RQ[op_type])->size;
for (fu_nu = 0; fu_nu < size; fu_nu++) {
portNu = GetNodeSrcNu(op_type);
for (port_nu = 0; port_nu < portNu; port_nu++) {
head = (MuxRAT[op_type][fu_nu]).Fu_portNu[port_nu];
if (head != NULL) {
p = head;
// For each loop, go to the last node and delete it
while (p != NULL) {
p2 = p;
p1 = p->next;
if (p1 != NULL) {
while (p1->next != NULL) {
p2 = p1;
p1 = p1->next;
}
p2->next = p1->next;
free(p1->Mi->constNu);
free(p1->Mi->constNu_d);
free(p1->Mi->regNu );
free(p1->Mi->destNu );
free(p1->Mi->muxNu );
free(p1->Mi->fuNu );
free(p1->Mo->regNu );
free(p1->Mo->muxNu );
free(p1->Mo->fuNu );
free(p1->Mi);
free(p1->Mo);
free(p1);
p = head;
} else {
free(p->Mi->constNu);
free(p->Mi->constNu_d);
free(p->Mi->regNu );
free(p->Mi->destNu );
free(p->Mi->muxNu );
free(p->Mi->fuNu );
free(p->Mo->regNu );
free(p->Mo->muxNu );
free(p->Mo->fuNu );
free(p->Mi);
free(p->Mo);
free(p);
break;
}
}
}
}
}
}
}
void FreeMuxRAT() {
enum operation op_type;
int fu_nu, port_nu;
int size;
FreeMuxList();
for (op_type = add; op_type < add + OP_NU; op_type++) {
size = (*RQ[op_type])->size;
for (fu_nu = 0; fu_nu < size; fu_nu++)
free((MuxRAT[op_type][fu_nu]).Fu_portNu);
free(MuxRAT[op_type]);
}
free(MuxRAT);
}
| [
"jinz@graviton.cse.sc.edu"
] | jinz@graviton.cse.sc.edu |
b8d4d277b54ca7630bf4f5df79d19f305bbc0510 | fa9215f85731a79cdd4b54ee7241c0f268a6ccba | /vendor/github.com/bep/gowebp/internal/libwebp/color_cache_utils.c | c3626e004509fed168db86d76570c66a5100bdcc | [
"Apache-2.0",
"MIT"
] | permissive | tischda/hugo-search | ada6a2fef26e0968415984764cc27f727c771d4e | 3d199a6617ac0631dfdc65f94e7948b246f4319c | refs/heads/master | 2023-04-29T18:27:48.857206 | 2023-04-24T18:41:38 | 2023-04-24T18:41:38 | 55,363,213 | 15 | 2 | Apache-2.0 | 2023-04-24T18:41:40 | 2016-04-03T18:56:51 | JavaScript | UTF-8 | C | false | false | 89 | c | #ifndef LIBWEBP_NO_SRC
#include "../../libwebp_src/src/utils/color_cache_utils.c"
#endif
| [
"dos.7182@gmail.com"
] | dos.7182@gmail.com |
f81ffc91cf8989fe8e07e928c2cf804e5403db08 | 305060aad7b92a8d7020d9576e2db8c7adf06945 | /0x0A-argc_argv/4-add.c | 74d69c9f1c90ae2e63710848e6a72151db4ac74d | [] | no_license | yulyzulu/holbertonschool-low_level_programming | 3e2ed2b8517d06a64747fa1dd4232059e66e8877 | 764fc905f84868cf52265b490d52ad5134e91f96 | refs/heads/master | 2020-07-28T12:11:13.734376 | 2020-04-16T15:14:56 | 2020-04-16T15:14:56 | 209,404,980 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 467 | c | #include <stdio.h>
#include <stdlib.h>
/**
*main- adds positive numbers
*@argc: integer
*@argv: array
*Return: integer
*/
int main(int argc, char *argv[])
{
int i, j, sum = 0;
if (argc == 1)
{
printf("%d\n", 0);
return (0);
}
for (i = 1; i < argc; i++)
{
for (j = 0; argv[i][j]; j++)
{
if (argv[i][j] < '0' || argv[i][j] > '9')
{
printf("Error\n");
return (1);
}
}
sum = sum + atoi(argv[i]);
}
printf("%d\n", sum);
return (0);
}
| [
"yulyzulu05@gmail.com"
] | yulyzulu05@gmail.com |
b04fa3b54aadbbd5ff78f3bb4c7fcf88b3b984f4 | 58106ce586d67ed1f3128bb974860aa62cb175af | /src/ceph/mon_client.c | a246dddb84c289e07c7f3530d00d3e6c27306234 | [] | no_license | murolo/pech | ce1f4e0820eb07c138484140080074c01592be73 | 155819e0680b8b203d561140b41af02c36535251 | refs/heads/master | 2022-05-25T14:20:25.840370 | 2020-04-08T10:06:12 | 2020-04-09T08:49:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 41,869 | c | // SPDX-License-Identifier: GPL-2.0
#include "ceph/ceph_debug.h"
#include "module.h"
#include "types.h"
#include "slab.h"
#include "random.h"
#include "sched.h"
#include <linux/utsname.h>
#include "ceph/ceph_features.h"
#include "ceph/mon_client.h"
#include "ceph/libceph.h"
#include "ceph/debugfs.h"
#include "ceph/decode.h"
#include "ceph/auth.h"
/*
* Interact with Ceph monitor cluster. Handle requests for new map
* versions, and periodically resend as needed. Also implement
* statfs() and umount().
*
* A small cluster of Ceph "monitors" are responsible for managing critical
* cluster configuration and state information. An odd number (e.g., 3, 5)
* of cmon daemons use a modified version of the Paxos part-time parliament
* algorithm to manage the MDS map (mds cluster membership), OSD map, and
* list of clients who have mounted the file system.
*
* We maintain an open, active session with a monitor at all times in order to
* receive timely MDSMap updates. We periodically send a keepalive byte on the
* TCP socket to ensure we detect a failure. If the connection does break, we
* randomly hunt for a new monitor. Once the connection is reestablished, we
* resend any outstanding requests.
*/
static const struct ceph_connection_operations mon_con_ops;
static int __validate_auth(struct ceph_mon_client *monc);
/*
* Decode a monmap blob (e.g., during mount).
*/
static struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
{
struct ceph_monmap *m = NULL;
int i, err = -EINVAL;
struct ceph_fsid fsid;
u32 epoch, num_mon;
u32 len;
ceph_decode_32_safe(&p, end, len, bad);
ceph_decode_need(&p, end, len, bad);
dout("monmap_decode %p %p len %d (%d)\n", p, end, len, (int)(end-p));
p += sizeof(u16); /* skip version */
ceph_decode_need(&p, end, sizeof(fsid) + 2*sizeof(u32), bad);
ceph_decode_copy(&p, &fsid, sizeof(fsid));
epoch = ceph_decode_32(&p);
num_mon = ceph_decode_32(&p);
if (num_mon > CEPH_MAX_MON)
goto bad;
m = kmalloc(struct_size(m, mon_inst, num_mon), GFP_NOFS);
if (m == NULL)
return ERR_PTR(-ENOMEM);
m->fsid = fsid;
m->epoch = epoch;
m->num_mon = num_mon;
for (i = 0; i < num_mon; ++i) {
struct ceph_entity_inst *inst = &m->mon_inst[i];
/* copy name portion */
ceph_decode_copy_safe(&p, end, &inst->name,
sizeof(inst->name), bad);
err = ceph_decode_entity_addr(&p, end, &inst->addr);
if (err)
goto bad;
}
dout("monmap_decode epoch %d, num_mon %d\n", m->epoch,
m->num_mon);
for (i = 0; i < m->num_mon; i++)
dout("monmap_decode mon%d is %s\n", i,
ceph_pr_addr(&m->mon_inst[i].addr));
return m;
bad:
dout("monmap_decode failed with %d\n", err);
kfree(m);
return ERR_PTR(err);
}
/*
* return true if *addr is included in the monmap.
*/
int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr)
{
int i;
for (i = 0; i < m->num_mon; i++)
if (memcmp(addr, &m->mon_inst[i].addr, sizeof(*addr)) == 0)
return 1;
return 0;
}
/*
* Send an auth request.
*/
static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
{
monc->pending_auth = 1;
monc->m_auth->front.iov_len = len;
monc->m_auth->hdr.front_len = cpu_to_le32(len);
ceph_msg_revoke(monc->m_auth);
ceph_msg_get(monc->m_auth); /* keep our ref */
ceph_con_send(&monc->con, monc->m_auth);
}
/*
* Close monitor session, if any.
*/
static void __close_session(struct ceph_mon_client *monc)
{
dout("__close_session closing mon%d\n", monc->cur_mon);
ceph_msg_revoke(monc->m_auth);
ceph_msg_revoke_incoming(monc->m_auth_reply);
ceph_msg_revoke(monc->m_subscribe);
ceph_msg_revoke_incoming(monc->m_subscribe_ack);
ceph_con_close(&monc->con);
monc->pending_auth = 0;
ceph_auth_reset(monc->auth);
}
/*
* Pick a new monitor at random and set cur_mon. If we are repicking
* (i.e. cur_mon is already set), be sure to pick a different one.
*/
static void pick_new_mon(struct ceph_mon_client *monc)
{
int old_mon = monc->cur_mon;
BUG_ON(monc->monmap->num_mon < 1);
if (monc->monmap->num_mon == 1) {
monc->cur_mon = 0;
} else {
int max = monc->monmap->num_mon;
int o = -1;
int n;
if (monc->cur_mon >= 0) {
if (monc->cur_mon < monc->monmap->num_mon)
o = monc->cur_mon;
if (o >= 0)
max--;
}
n = prandom_u32() % max;
if (o >= 0 && n >= o)
n++;
monc->cur_mon = n;
}
dout("%s mon%d -> mon%d out of %d mons\n", __func__, old_mon,
monc->cur_mon, monc->monmap->num_mon);
}
/*
* Open a session with a new monitor.
*/
static void __open_session(struct ceph_mon_client *monc)
{
int ret;
pick_new_mon(monc);
monc->hunting = true;
if (monc->had_a_connection) {
monc->hunt_mult *= CEPH_MONC_HUNT_BACKOFF;
if (monc->hunt_mult > CEPH_MONC_HUNT_MAX_MULT)
monc->hunt_mult = CEPH_MONC_HUNT_MAX_MULT;
}
monc->sub_renew_after = jiffies; /* i.e., expired */
monc->sub_renew_sent = 0;
dout("%s opening mon%d\n", __func__, monc->cur_mon);
ceph_con_open(&monc->con, CEPH_ENTITY_TYPE_MON, monc->cur_mon,
&monc->monmap->mon_inst[monc->cur_mon].addr);
/*
* send an initial keepalive to ensure our timestamp is valid
* by the time we are in an OPENED state
*/
ceph_con_keepalive(&monc->con);
/* initiate authentication handshake */
ret = ceph_auth_build_hello(monc->auth,
monc->m_auth->front.iov_base,
monc->m_auth->front_alloc_len);
BUG_ON(ret <= 0);
__send_prepared_auth_request(monc, ret);
}
static void reopen_session(struct ceph_mon_client *monc)
{
if (!monc->hunting)
pr_info("mon%d %s session lost, hunting for new mon\n",
monc->cur_mon, ceph_pr_addr(&monc->con.peer_addr));
__close_session(monc);
__open_session(monc);
}
void ceph_monc_reopen_session(struct ceph_mon_client *monc)
{
mutex_lock(&monc->mutex);
reopen_session(monc);
mutex_unlock(&monc->mutex);
}
static void un_backoff(struct ceph_mon_client *monc)
{
monc->hunt_mult /= 2; /* reduce by 50% */
if (monc->hunt_mult < 1)
monc->hunt_mult = 1;
dout("%s hunt_mult now %d\n", __func__, monc->hunt_mult);
}
/*
* Reschedule delayed work timer.
*/
static void __schedule_delayed(struct ceph_mon_client *monc)
{
unsigned long delay;
if (monc->hunting)
delay = CEPH_MONC_HUNT_INTERVAL * monc->hunt_mult;
else
delay = CEPH_MONC_PING_INTERVAL;
dout("__schedule_delayed after %lu\n", delay);
mod_delayed_work(system_wq, &monc->delayed_work,
round_jiffies_relative(delay));
}
/*
* Reschedule beacon send
*/
static void __schedule_beacon_send(struct ceph_mon_client *monc)
{
struct ceph_messenger *msgr = &monc->client->msgr;
unsigned long delay = CEPH_MONC_BEACON_INTERVAL;
if (msgr->inst.name.type != CEPH_ENTITY_TYPE_OSD)
/* This is only for OSD */
return;
dout("__schedule_beacon_send after %lu\n", delay);
mod_delayed_work(system_wq, &monc->beacon_work,
round_jiffies_relative(delay));
}
const char *ceph_sub_str[] = {
[CEPH_SUB_MONMAP] = "monmap",
[CEPH_SUB_OSDMAP] = "osdmap",
[CEPH_SUB_FSMAP] = "fsmap.user",
[CEPH_SUB_MDSMAP] = "mdsmap",
};
/*
* Send subscribe request for one or more maps, according to
* monc->subs.
*/
static void __send_subscribe(struct ceph_mon_client *monc)
{
struct ceph_msg *msg = monc->m_subscribe;
void *p = msg->front.iov_base;
void *const end = p + msg->front_alloc_len;
int num = 0;
int i;
dout("%s sent %lu\n", __func__, monc->sub_renew_sent);
BUG_ON(monc->cur_mon < 0);
if (!monc->sub_renew_sent)
monc->sub_renew_sent = jiffies | 1; /* never 0 */
msg->hdr.version = cpu_to_le16(2);
for (i = 0; i < ARRAY_SIZE(monc->subs); i++) {
if (monc->subs[i].want)
num++;
}
BUG_ON(num < 1); /* monmap sub is always there */
ceph_encode_32(&p, num);
for (i = 0; i < ARRAY_SIZE(monc->subs); i++) {
char buf[32];
int len;
if (!monc->subs[i].want)
continue;
len = sprintf(buf, "%s", ceph_sub_str[i]);
if (i == CEPH_SUB_MDSMAP &&
monc->fs_cluster_id != CEPH_FS_CLUSTER_ID_NONE)
len += sprintf(buf + len, ".%d", monc->fs_cluster_id);
dout("%s %s start %llu flags 0x%x\n", __func__, buf,
le64_to_cpu(monc->subs[i].item.start),
monc->subs[i].item.flags);
ceph_encode_string(&p, end, buf, len);
memcpy(p, &monc->subs[i].item, sizeof(monc->subs[i].item));
p += sizeof(monc->subs[i].item);
}
BUG_ON(p > end);
msg->front.iov_len = p - msg->front.iov_base;
msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
ceph_msg_revoke(msg);
ceph_con_send(&monc->con, ceph_msg_get(msg));
}
static void handle_subscribe_ack(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
unsigned int seconds;
struct ceph_mon_subscribe_ack *h = msg->front.iov_base;
if (msg->front.iov_len < sizeof(*h))
goto bad;
seconds = le32_to_cpu(h->duration);
mutex_lock(&monc->mutex);
if (monc->sub_renew_sent) {
/*
* This is only needed for legacy (infernalis or older)
* MONs -- see delayed_work().
*/
monc->sub_renew_after = monc->sub_renew_sent +
(seconds >> 1) * HZ - 1;
dout("%s sent %lu duration %d renew after %lu\n", __func__,
monc->sub_renew_sent, seconds, monc->sub_renew_after);
monc->sub_renew_sent = 0;
} else {
dout("%s sent %lu renew after %lu, ignoring\n", __func__,
monc->sub_renew_sent, monc->sub_renew_after);
}
mutex_unlock(&monc->mutex);
return;
bad:
pr_err("got corrupt subscribe-ack msg\n");
ceph_msg_dump(msg);
}
/*
* Register interest in a map
*
* @sub: one of CEPH_SUB_*
* @epoch: X for "every map since X", or 0 for "just the latest"
*/
static bool __ceph_monc_want_map(struct ceph_mon_client *monc, int sub,
u32 epoch, bool continuous)
{
__le64 start = cpu_to_le64(epoch);
u8 flags = !continuous ? CEPH_SUBSCRIBE_ONETIME : 0;
dout("%s %s epoch %u continuous %d\n", __func__, ceph_sub_str[sub],
epoch, continuous);
if (monc->subs[sub].want &&
monc->subs[sub].item.start == start &&
monc->subs[sub].item.flags == flags)
return false;
monc->subs[sub].item.start = start;
monc->subs[sub].item.flags = flags;
monc->subs[sub].want = true;
return true;
}
bool ceph_monc_want_map(struct ceph_mon_client *monc, int sub, u32 epoch,
bool continuous)
{
bool need_request;
mutex_lock(&monc->mutex);
need_request = __ceph_monc_want_map(monc, sub, epoch, continuous);
mutex_unlock(&monc->mutex);
return need_request;
}
EXPORT_SYMBOL(ceph_monc_want_map);
/*
* Keep track of which maps we have
*
* @sub: one of CEPH_SUB_*
*/
static void __ceph_monc_got_map(struct ceph_mon_client *monc, int sub,
u32 epoch)
{
dout("%s %s epoch %u\n", __func__, ceph_sub_str[sub], epoch);
if (monc->subs[sub].want) {
if (monc->subs[sub].item.flags & CEPH_SUBSCRIBE_ONETIME)
monc->subs[sub].want = false;
else
monc->subs[sub].item.start = cpu_to_le64(epoch + 1);
}
monc->subs[sub].have = epoch;
}
void ceph_monc_got_map(struct ceph_mon_client *monc, int sub, u32 epoch)
{
mutex_lock(&monc->mutex);
__ceph_monc_got_map(monc, sub, epoch);
mutex_unlock(&monc->mutex);
}
EXPORT_SYMBOL(ceph_monc_got_map);
void ceph_monc_renew_subs(struct ceph_mon_client *monc)
{
mutex_lock(&monc->mutex);
__send_subscribe(monc);
mutex_unlock(&monc->mutex);
}
EXPORT_SYMBOL(ceph_monc_renew_subs);
/*
* Wait for an osdmap with a given epoch.
*
* @epoch: epoch to wait for
* @timeout: in jiffies, 0 means "wait forever"
*/
int ceph_monc_wait_osdmap(struct ceph_mon_client *monc, u32 epoch,
unsigned long timeout)
{
unsigned long started = jiffies;
long ret;
mutex_lock(&monc->mutex);
while (monc->subs[CEPH_SUB_OSDMAP].have < epoch) {
mutex_unlock(&monc->mutex);
if (timeout && time_after_eq(jiffies, started + timeout))
return -ETIMEDOUT;
ret = wait_event_interruptible_timeout(monc->client->auth_wq,
monc->subs[CEPH_SUB_OSDMAP].have >= epoch,
ceph_timeout_jiffies(timeout));
if (ret < 0)
return ret;
mutex_lock(&monc->mutex);
}
mutex_unlock(&monc->mutex);
return 0;
}
EXPORT_SYMBOL(ceph_monc_wait_osdmap);
/*
* Open a session with a random monitor. Request monmap and osdmap,
* which are waited upon in __ceph_open_session().
*/
int ceph_monc_open_session(struct ceph_mon_client *monc)
{
mutex_lock(&monc->mutex);
__ceph_monc_want_map(monc, CEPH_SUB_MONMAP, 0, true);
__ceph_monc_want_map(monc, CEPH_SUB_OSDMAP, 0, false);
__open_session(monc);
__schedule_delayed(monc);
__schedule_beacon_send(monc);
mutex_unlock(&monc->mutex);
return 0;
}
EXPORT_SYMBOL(ceph_monc_open_session);
static void ceph_monc_handle_map(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
struct ceph_client *client = monc->client;
struct ceph_monmap *monmap = NULL, *old = monc->monmap;
void *p, *end;
mutex_lock(&monc->mutex);
dout("handle_monmap\n");
p = msg->front.iov_base;
end = p + msg->front.iov_len;
monmap = ceph_monmap_decode(p, end);
if (IS_ERR(monmap)) {
pr_err("problem decoding monmap, %d\n",
(int)PTR_ERR(monmap));
ceph_msg_dump(msg);
goto out;
}
if (ceph_check_fsid(monc->client, &monmap->fsid) < 0) {
kfree(monmap);
goto out;
}
client->monc.monmap = monmap;
kfree(old);
__ceph_monc_got_map(monc, CEPH_SUB_MONMAP, monc->monmap->epoch);
client->have_fsid = true;
out:
mutex_unlock(&monc->mutex);
wake_up_all(&client->auth_wq);
}
/*
* generic requests (currently statfs, mon_get_version)
*/
DEFINE_RB_FUNCS(generic_request, struct ceph_mon_generic_request, tid, node)
static void release_generic_request(struct kref *kref)
{
struct ceph_mon_generic_request *req =
container_of(kref, struct ceph_mon_generic_request, kref);
dout("%s greq %p request %p reply %p\n", __func__, req, req->request,
req->reply);
WARN_ON(!RB_EMPTY_NODE(&req->node));
if (req->reply)
ceph_msg_put(req->reply);
if (req->request)
ceph_msg_put(req->request);
kfree(req);
}
static void put_generic_request(struct ceph_mon_generic_request *req)
{
if (req)
kref_put(&req->kref, release_generic_request);
}
static void get_generic_request(struct ceph_mon_generic_request *req)
{
kref_get(&req->kref);
}
static struct ceph_mon_generic_request *
alloc_generic_request(struct ceph_mon_client *monc, gfp_t gfp)
{
struct ceph_mon_generic_request *req;
req = kzalloc(sizeof(*req), gfp);
if (!req)
return NULL;
req->monc = monc;
kref_init(&req->kref);
RB_CLEAR_NODE(&req->node);
init_completion(&req->completion);
dout("%s greq %p\n", __func__, req);
return req;
}
static void set_tid_generic_request(struct ceph_mon_generic_request *req)
{
struct ceph_mon_client *monc = req->monc;
req->tid = ++monc->last_tid;
}
static void register_generic_request(struct ceph_mon_generic_request *req)
{
struct ceph_mon_client *monc = req->monc;
WARN_ON(req->tid);
get_generic_request(req);
set_tid_generic_request(req);
insert_generic_request(&monc->generic_request_tree, req);
}
static void send_generic_request(struct ceph_mon_client *monc,
struct ceph_mon_generic_request *req)
{
WARN_ON(!req->tid);
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
req->request->hdr.tid = cpu_to_le64(req->tid);
ceph_con_send(&monc->con, ceph_msg_get(req->request));
}
static void __finish_generic_request(struct ceph_mon_generic_request *req)
{
struct ceph_mon_client *monc = req->monc;
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
erase_generic_request(&monc->generic_request_tree, req);
ceph_msg_revoke(req->request);
ceph_msg_revoke_incoming(req->reply);
}
static void finish_generic_request(struct ceph_mon_generic_request *req)
{
__finish_generic_request(req);
put_generic_request(req);
}
static void complete_generic_request(struct ceph_mon_generic_request *req)
{
if (req->complete_cb)
req->complete_cb(req);
else
complete_all(&req->completion);
put_generic_request(req);
}
static void cancel_generic_request(struct ceph_mon_generic_request *req)
{
struct ceph_mon_client *monc = req->monc;
struct ceph_mon_generic_request *lookup_req;
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
mutex_lock(&monc->mutex);
lookup_req = lookup_generic_request(&monc->generic_request_tree,
req->tid);
if (lookup_req) {
WARN_ON(lookup_req != req);
finish_generic_request(req);
}
mutex_unlock(&monc->mutex);
}
static int wait_generic_request(struct ceph_mon_generic_request *req)
{
int ret;
dout("%s greq %p tid %llu\n", __func__, req, req->tid);
ret = wait_for_completion_interruptible(&req->completion);
if (ret)
cancel_generic_request(req);
else
ret = req->result; /* completed */
return ret;
}
static struct ceph_msg *get_generic_reply(struct ceph_connection *con,
struct ceph_msg_header *hdr,
int *skip)
{
struct ceph_mon_client *monc = con->private;
struct ceph_mon_generic_request *req;
u64 tid = le64_to_cpu(hdr->tid);
struct ceph_msg *m;
mutex_lock(&monc->mutex);
req = lookup_generic_request(&monc->generic_request_tree, tid);
if (!req) {
dout("get_generic_reply %lld dne\n", tid);
*skip = 1;
m = NULL;
} else {
dout("get_generic_reply %lld got %p\n", tid, req->reply);
if (req->reply) {
*skip = 0;
m = ceph_msg_get(req->reply);
} else {
*skip = 1;
m = NULL;
}
/*
* we don't need to track the connection reading into
* this reply because we only have one open connection
* at a time, ever.
*/
}
mutex_unlock(&monc->mutex);
return m;
}
/*
* statfs
*/
static void handle_statfs_reply(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
struct ceph_mon_generic_request *req;
struct ceph_mon_statfs_reply *reply = msg->front.iov_base;
u64 tid = le64_to_cpu(msg->hdr.tid);
dout("%s msg %p tid %llu\n", __func__, msg, tid);
if (msg->front.iov_len != sizeof(*reply))
goto bad;
mutex_lock(&monc->mutex);
req = lookup_generic_request(&monc->generic_request_tree, tid);
if (!req) {
mutex_unlock(&monc->mutex);
return;
}
req->result = 0;
*req->u.st = reply->st; /* struct */
__finish_generic_request(req);
mutex_unlock(&monc->mutex);
complete_generic_request(req);
return;
bad:
pr_err("corrupt statfs reply, tid %llu\n", tid);
ceph_msg_dump(msg);
}
/*
* Do a synchronous statfs().
*/
int ceph_monc_do_statfs(struct ceph_mon_client *monc, u64 data_pool,
struct ceph_statfs *buf)
{
struct ceph_mon_generic_request *req;
struct ceph_mon_statfs *h;
int ret = -ENOMEM;
req = alloc_generic_request(monc, GFP_NOFS);
if (!req)
goto out;
req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS,
true);
if (!req->request)
goto out;
req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 64, GFP_NOFS, true);
if (!req->reply)
goto out;
req->u.st = buf;
req->request->hdr.version = cpu_to_le16(2);
mutex_lock(&monc->mutex);
register_generic_request(req);
/* fill out request */
h = req->request->front.iov_base;
h->monhdr.have_version = 0;
h->monhdr.session_mon = cpu_to_le16(-1);
h->monhdr.session_mon_tid = 0;
h->fsid = monc->monmap->fsid;
h->contains_data_pool = (data_pool != CEPH_NOPOOL);
h->data_pool = cpu_to_le64(data_pool);
send_generic_request(monc, req);
mutex_unlock(&monc->mutex);
ret = wait_generic_request(req);
out:
put_generic_request(req);
return ret;
}
EXPORT_SYMBOL(ceph_monc_do_statfs);
static void handle_get_version_reply(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
struct ceph_mon_generic_request *req;
u64 tid = le64_to_cpu(msg->hdr.tid);
void *p = msg->front.iov_base;
void *end = p + msg->front_alloc_len;
u64 handle;
dout("%s msg %p tid %llu\n", __func__, msg, tid);
ceph_decode_need(&p, end, 2*sizeof(u64), bad);
handle = ceph_decode_64(&p);
if (tid != 0 && tid != handle)
goto bad;
mutex_lock(&monc->mutex);
req = lookup_generic_request(&monc->generic_request_tree, handle);
if (!req) {
mutex_unlock(&monc->mutex);
return;
}
req->result = 0;
req->u.newest = ceph_decode_64(&p);
__finish_generic_request(req);
mutex_unlock(&monc->mutex);
complete_generic_request(req);
return;
bad:
pr_err("corrupt mon_get_version reply, tid %llu\n", tid);
ceph_msg_dump(msg);
}
static struct ceph_mon_generic_request *
__ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
ceph_monc_callback_t cb, u64 private_data)
{
struct ceph_mon_generic_request *req;
req = alloc_generic_request(monc, GFP_NOIO);
if (!req)
goto err_put_req;
req->request = ceph_msg_new(CEPH_MSG_MON_GET_VERSION,
sizeof(u64) + sizeof(u32) + strlen(what),
GFP_NOIO, true);
if (!req->request)
goto err_put_req;
req->reply = ceph_msg_new(CEPH_MSG_MON_GET_VERSION_REPLY, 32, GFP_NOIO,
true);
if (!req->reply)
goto err_put_req;
req->complete_cb = cb;
req->private_data = private_data;
mutex_lock(&monc->mutex);
register_generic_request(req);
{
void *p = req->request->front.iov_base;
void *const end = p + req->request->front_alloc_len;
ceph_encode_64(&p, req->tid); /* handle */
ceph_encode_string(&p, end, what, strlen(what));
WARN_ON(p != end);
}
send_generic_request(monc, req);
mutex_unlock(&monc->mutex);
return req;
err_put_req:
put_generic_request(req);
return ERR_PTR(-ENOMEM);
}
/*
* Send MMonGetVersion and wait for the reply.
*
* @what: one of "mdsmap", "osdmap" or "monmap"
*/
int ceph_monc_get_version(struct ceph_mon_client *monc, const char *what,
u64 *newest)
{
struct ceph_mon_generic_request *req;
int ret;
req = __ceph_monc_get_version(monc, what, NULL, 0);
if (IS_ERR(req))
return PTR_ERR(req);
ret = wait_generic_request(req);
if (!ret)
*newest = req->u.newest;
put_generic_request(req);
return ret;
}
EXPORT_SYMBOL(ceph_monc_get_version);
/*
* Send MMonGetVersion,
*
* @what: one of "mdsmap", "osdmap" or "monmap"
*/
int ceph_monc_get_version_async(struct ceph_mon_client *monc, const char *what,
ceph_monc_callback_t cb, u64 private_data)
{
struct ceph_mon_generic_request *req;
req = __ceph_monc_get_version(monc, what, cb, private_data);
if (IS_ERR(req))
return PTR_ERR(req);
put_generic_request(req);
return 0;
}
EXPORT_SYMBOL(ceph_monc_get_version_async);
static void handle_command_ack(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
struct ceph_mon_generic_request *req;
void *p = msg->front.iov_base;
void *const end = p + msg->front_alloc_len;
u64 tid = le64_to_cpu(msg->hdr.tid);
dout("%s msg %p tid %llu\n", __func__, msg, tid);
ceph_decode_need(&p, end, sizeof(struct ceph_mon_request_header) +
sizeof(u32), bad);
p += sizeof(struct ceph_mon_request_header);
mutex_lock(&monc->mutex);
req = lookup_generic_request(&monc->generic_request_tree, tid);
if (!req) {
mutex_unlock(&monc->mutex);
return;
}
req->result = ceph_decode_32(&p);
__finish_generic_request(req);
mutex_unlock(&monc->mutex);
complete_generic_request(req);
return;
bad:
pr_err("corrupt mon_command ack, tid %llu\n", tid);
ceph_msg_dump(msg);
}
__printf(2, 3)
static int ceph_monc_send_command_and_wait(struct ceph_mon_client *monc,
const char *format, ...)
{
struct ceph_mon_generic_request *req;
struct ceph_mon_command *h;
va_list args;
/* 256 bytes should be enough */
const size_t max_sz = 256;
int ret = -ENOMEM;
int len;
req = alloc_generic_request(monc, GFP_NOIO);
if (!req)
goto out;
req->request = ceph_msg_new(CEPH_MSG_MON_COMMAND, max_sz, GFP_NOIO,
true);
if (!req->request)
goto out;
req->reply = ceph_msg_new(CEPH_MSG_MON_COMMAND_ACK, 512, GFP_NOIO,
true);
if (!req->reply)
goto out;
h = req->request->front.iov_base;
h->monhdr.have_version = 0;
h->monhdr.session_mon = cpu_to_le16(-1);
h->monhdr.session_mon_tid = 0;
h->fsid = monc->monmap->fsid;
h->num_strs = cpu_to_le32(1);
va_start(args, format);
len = vsnprintf(h->str, max_sz - sizeof(*h), format, args);
va_end(args);
h->str_len = cpu_to_le32(len);
if (WARN_ON(len >= max_sz)) {
ret = -EOVERFLOW;
goto out;
}
mutex_lock(&monc->mutex);
register_generic_request(req);
send_generic_request(monc, req);
mutex_unlock(&monc->mutex);
ret = wait_generic_request(req);
out:
put_generic_request(req);
return ret;
}
int ceph_monc_blacklist_add(struct ceph_mon_client *monc,
struct ceph_entity_addr *client_addr)
{
const char *fmt = "{ \"prefix\": \"osd blacklist\", \
\"blacklistop\": \"add\", \
\"addr\": \"%pISpc/%u\" }";
int ret;
ret = ceph_monc_send_command_and_wait(monc, fmt,
&client_addr->in_addr,
le32_to_cpu(client_addr->nonce));
if (!ret)
/*
* Make sure we have the osdmap that includes the blacklist
* entry. This is needed to ensure that the OSDs pick up the
* new blacklist before processing any future requests from
* this client.
*/
ret = ceph_wait_for_latest_osdmap(monc->client, 0);
return ret;
}
EXPORT_SYMBOL(ceph_monc_blacklist_add);
int ceph_monc_osd_to_crush_add(struct ceph_mon_client *monc,
int osd_id, const char *weight)
{
/* FIXME: crush location is hardcoded for now */
const char *fmt = "{ \"prefix\": \"osd crush create-or-move\", \
\"id\": %d, \
\"weight\": %s, \
\"args\": [\"host=%s\", \"root=default\"] }";
int ret = ceph_monc_send_command_and_wait(monc, fmt, osd_id, weight,
utsname()->nodename);
return ret;
}
EXPORT_SYMBOL(ceph_monc_osd_to_crush_add);
int ceph_monc_osd_boot(struct ceph_mon_client *monc, int osd_id,
struct ceph_fsid *osd_fsid)
{
struct ceph_osd_boot *cmd, osd_boot_cmd = {
.monhdr = {
.have_version = cpu_to_le64(monc->monmap->epoch),
.session_mon = cpu_to_le16(-1),
.session_mon_tid = 0,
},
.sb = {
.struct_version = {
.struct_v = 9,
.struct_compat = 5,
.struct_len = cpu_to_le32(
sizeof(osd_boot_cmd.sb) -
sizeof(osd_boot_cmd.sb.struct_version))
},
.cluster_fsid = monc->monmap->fsid,
.whoami = cpu_to_le32(osd_id),
.osd_fsid = *osd_fsid,
},
};
struct ceph_mon_generic_request *req;
void *p, *end;
/* XXX */
struct ceph_entity_addr hb_back_addr = {
.in_addr.ss_family = AF_INET
};
struct ceph_entity_addr hb_front_addr = {
.in_addr.ss_family = AF_INET
};
struct ceph_entity_addr cluster_addr = {
.in_addr.ss_family = AF_INET
};
int ret = -ENOMEM;
req = alloc_generic_request(monc, GFP_NOIO);
if (!req)
goto out;
req->request = ceph_msg_new(CEPH_MSG_OSD_BOOT, 512,
GFP_NOIO, true);
if (!req->request)
goto out;
cmd = req->request->front.iov_base;
*cmd = osd_boot_cmd;
p = cmd + 1;
end = p + req->request->front_alloc_len - sizeof(*cmd);
if (CEPH_HAVE_FEATURE(monc->con.peer_features, SERVER_NAUTILUS)) {
req->request->hdr.version = cpu_to_le16(7);
req->request->hdr.compat_version = cpu_to_le16(7);
} else {
/* Compat path */
req->request->hdr.version = cpu_to_le16(6);
req->request->hdr.compat_version = cpu_to_le16(6);
}
ceph_encode_single_entity_addrvec(&p, end, &hb_back_addr,
monc->con.peer_features);
ceph_encode_single_entity_addrvec(&p, end, &cluster_addr,
monc->con.peer_features);
/* boot_epoch */
ceph_encode_32_safe(&p, end, monc->monmap->epoch, bad);
ceph_encode_single_entity_addrvec(&p, end, &hb_front_addr,
monc->con.peer_features);
/* metadata map which size is 0 */
ceph_encode_32_safe(&p, end, 0, bad);
/* osd_features */
ceph_encode_64_safe(&p, end, CEPH_FEATURES_ALL, bad);
mutex_lock(&monc->mutex);
set_tid_generic_request(req);
send_generic_request(monc, req);
mutex_unlock(&monc->mutex);
ret = 0;
out:
put_generic_request(req);
return ret;
bad:
WARN(1, "Small buffer size?\n");
put_generic_request(req);
ret = -EINVAL;
goto out;
}
EXPORT_SYMBOL(ceph_monc_osd_boot);
int ceph_monc_osd_mark_me_down(struct ceph_mon_client *monc, int osd_id)
{
struct ceph_osd_mark_me_down *cmd, osd_mark_me_down_cmd = {
.monhdr = {
.have_version = cpu_to_le64(monc->monmap->epoch),
.session_mon = cpu_to_le16(-1),
.session_mon_tid = 0,
},
.fsid = monc->monmap->fsid,
};
struct ceph_mon_generic_request *req;
void *p, *end;
int ret;
if (monc->hunting)
/*
* Check a variable even without a lock, just leave
* the function immediately if not connected.
*/
return -ENOTCONN;
ret = -ENOMEM;
req = alloc_generic_request(monc, GFP_NOIO);
if (!req)
return ret;
req->request = ceph_msg_new(CEPH_MSG_OSD_MARK_ME_DOWN, 256,
GFP_NOIO, true);
if (!req->request)
goto out;
cmd = req->request->front.iov_base;
*cmd = osd_mark_me_down_cmd;
p = cmd + 1;
end = p + req->request->front_alloc_len - sizeof(*cmd);
if (CEPH_HAVE_FEATURE(monc->con.peer_features, SERVER_NAUTILUS)) {
int ret;
req->request->hdr.version = cpu_to_le16(3);
req->request->hdr.compat_version = cpu_to_le16(3);
ceph_encode_32_safe(&p, end, osd_id, bad);
ret = ceph_encode_single_entity_addrvec(&p, end,
ceph_client_addr(monc->client),
monc->con.peer_features);
if (ret)
goto bad;
} else {
/* Compat path */
req->request->hdr.version = cpu_to_le16(2);
req->request->hdr.compat_version = cpu_to_le16(2);
/* XXX */
BUG();
#if 0
encode(entity_inst_t(entity_name_t::OSD(target_osd),
target_addrs.legacy_addr()),
payload, features);
#endif
}
ceph_encode_32_safe(&p, end, monc->monmap->epoch, bad);
/* Request ack */
ceph_encode_8_safe(&p, end, 1, bad);
mutex_lock(&monc->mutex);
reinit_completion(&monc->m_osd_marked_down_comp);
set_tid_generic_request(req);
send_generic_request(monc, req);
mutex_unlock(&monc->mutex);
ret = wait_for_completion_interruptible(&monc->m_osd_marked_down_comp);
out:
put_generic_request(req);
return ret;
bad:
WARN(1, "Small buffer size?\n");
put_generic_request(req);
ret = -EINVAL;
goto out;
}
EXPORT_SYMBOL(ceph_monc_osd_mark_me_down);
static int ceph_monc_osd_send_beacon(struct ceph_mon_client *monc)
{
struct ceph_osd_beacon *cmd, osd_beacon_cmd = {
.monhdr = {
.have_version = cpu_to_le64(monc->monmap->epoch),
.session_mon = cpu_to_le16(-1),
.session_mon_tid = 0,
},
.min_last_epoch_clean = cpu_to_le32(monc->monmap->epoch),
};
struct ceph_mon_generic_request *req;
int ret = -ENOMEM;
req = alloc_generic_request(monc, GFP_NOIO);
if (!req)
goto out;
req->request = ceph_msg_new(CEPH_MSG_OSD_BEACON, sizeof(*cmd),
GFP_NOIO, true);
if (!req->request)
goto out;
cmd = req->request->front.iov_base;
*cmd = osd_beacon_cmd;
mutex_lock(&monc->mutex);
set_tid_generic_request(req);
send_generic_request(monc, req);
mutex_unlock(&monc->mutex);
ret = 0;
out:
put_generic_request(req);
return ret;
}
/*
* Resend pending generic requests.
*/
static void __resend_generic_request(struct ceph_mon_client *monc)
{
struct ceph_mon_generic_request *req;
struct rb_node *p;
for (p = rb_first(&monc->generic_request_tree); p; p = rb_next(p)) {
req = rb_entry(p, struct ceph_mon_generic_request, node);
ceph_msg_revoke(req->request);
ceph_msg_revoke_incoming(req->reply);
ceph_con_send(&monc->con, ceph_msg_get(req->request));
}
}
/*
* Delayed work. If we haven't mounted yet, retry. Otherwise,
* renew/retry subscription as needed (in case it is timing out, or we
* got an ENOMEM). And keep the monitor connection alive.
*/
static void delayed_work(struct work_struct *work)
{
struct ceph_mon_client *monc =
container_of(work, struct ceph_mon_client, delayed_work.work);
dout("monc delayed_work\n");
mutex_lock(&monc->mutex);
if (monc->hunting) {
dout("%s continuing hunt\n", __func__);
reopen_session(monc);
} else {
int is_auth = ceph_auth_is_authenticated(monc->auth);
if (ceph_con_keepalive_expired(&monc->con,
CEPH_MONC_PING_TIMEOUT)) {
dout("monc keepalive timeout\n");
is_auth = 0;
reopen_session(monc);
}
if (!monc->hunting) {
ceph_con_keepalive(&monc->con);
__validate_auth(monc);
un_backoff(monc);
}
if (is_auth &&
!(monc->con.peer_features & CEPH_FEATURE_MON_STATEFUL_SUB)) {
unsigned long now = jiffies;
dout("%s renew subs? now %lu renew after %lu\n",
__func__, now, monc->sub_renew_after);
if (time_after_eq(now, monc->sub_renew_after))
__send_subscribe(monc);
}
}
__schedule_delayed(monc);
mutex_unlock(&monc->mutex);
}
/*
* Send beacon to monitors saying we are alive and healthy.
*/
static void send_beacon_work(struct work_struct *work)
{
struct ceph_mon_client *monc;
int ret;
monc = container_of(work, typeof(*monc), beacon_work.work);
dout("monc send_beacon_work\n");
ret = ceph_monc_osd_send_beacon(monc);
if (unlikely(ret))
pr_err("ceph_monc_osd_send_beacon: failed %d\n", ret);
/* Rearm work, it's ok here to rearm without locks */
__schedule_beacon_send(monc);
}
/*
* On startup, we build a temporary monmap populated with the IPs
* provided by mount(2).
*/
static int build_initial_monmap(struct ceph_mon_client *monc)
{
struct ceph_options *opt = monc->client->options;
struct ceph_entity_addr *mon_addr = opt->mon_addr;
int num_mon = opt->num_mon;
int i;
/* build initial monmap */
monc->monmap = kzalloc(struct_size(monc->monmap, mon_inst, num_mon),
GFP_KERNEL);
if (!monc->monmap)
return -ENOMEM;
for (i = 0; i < num_mon; i++) {
monc->monmap->mon_inst[i].addr = mon_addr[i];
monc->monmap->mon_inst[i].addr.nonce = 0;
monc->monmap->mon_inst[i].name.type =
CEPH_ENTITY_TYPE_MON;
monc->monmap->mon_inst[i].name.num = cpu_to_le64(i);
}
monc->monmap->num_mon = num_mon;
return 0;
}
int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
{
int err = 0;
dout("init\n");
memset(monc, 0, sizeof(*monc));
monc->client = cl;
monc->monmap = NULL;
mutex_init(&monc->mutex);
err = build_initial_monmap(monc);
if (err)
goto out;
/* connection */
/* authentication */
monc->auth = ceph_auth_init(cl->options->name,
cl->options->key);
if (IS_ERR(monc->auth)) {
err = PTR_ERR(monc->auth);
goto out_monmap;
}
monc->auth->want_keys =
CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON |
CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS;
/* msgs */
err = -ENOMEM;
monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK,
sizeof(struct ceph_mon_subscribe_ack),
GFP_KERNEL, true);
if (!monc->m_subscribe_ack)
goto out_auth;
monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 128,
GFP_KERNEL, true);
if (!monc->m_subscribe)
goto out_subscribe_ack;
monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096,
GFP_KERNEL, true);
if (!monc->m_auth_reply)
goto out_subscribe;
monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_KERNEL, true);
monc->pending_auth = 0;
if (!monc->m_auth)
goto out_auth_reply;
ceph_con_init(&monc->con, monc, &mon_con_ops,
&monc->client->msgr);
monc->cur_mon = -1;
monc->had_a_connection = false;
monc->hunt_mult = 1;
init_completion(&monc->m_osd_marked_down_comp);
INIT_DELAYED_WORK(&monc->delayed_work, delayed_work);
INIT_DELAYED_WORK(&monc->beacon_work, send_beacon_work);
monc->generic_request_tree = RB_ROOT;
monc->last_tid = 0;
monc->fs_cluster_id = CEPH_FS_CLUSTER_ID_NONE;
return 0;
out_auth_reply:
ceph_msg_put(monc->m_auth_reply);
out_subscribe:
ceph_msg_put(monc->m_subscribe);
out_subscribe_ack:
ceph_msg_put(monc->m_subscribe_ack);
out_auth:
ceph_auth_destroy(monc->auth);
out_monmap:
kfree(monc->monmap);
out:
return err;
}
EXPORT_SYMBOL(ceph_monc_init);
void ceph_monc_stop(struct ceph_mon_client *monc)
{
dout("stop\n");
cancel_delayed_work_sync(&monc->delayed_work);
cancel_delayed_work_sync(&monc->beacon_work);
mutex_lock(&monc->mutex);
__close_session(monc);
monc->cur_mon = -1;
mutex_unlock(&monc->mutex);
/*
* flush msgr queue before we destroy ourselves to ensure that:
* - any work that references our embedded con is finished.
* - any osd_client or other work that may reference an authorizer
* finishes before we shut down the auth subsystem.
*/
ceph_msgr_flush();
ceph_auth_destroy(monc->auth);
WARN_ON(!RB_EMPTY_ROOT(&monc->generic_request_tree));
ceph_msg_put(monc->m_auth);
ceph_msg_put(monc->m_auth_reply);
ceph_msg_put(monc->m_subscribe);
ceph_msg_put(monc->m_subscribe_ack);
kfree(monc->monmap);
}
EXPORT_SYMBOL(ceph_monc_stop);
static void finish_hunting(struct ceph_mon_client *monc)
{
if (monc->hunting) {
dout("%s found mon%d\n", __func__, monc->cur_mon);
monc->hunting = false;
monc->had_a_connection = true;
un_backoff(monc);
__schedule_delayed(monc);
}
}
static void handle_auth_reply(struct ceph_mon_client *monc,
struct ceph_msg *msg)
{
int ret;
int was_auth = 0;
mutex_lock(&monc->mutex);
was_auth = ceph_auth_is_authenticated(monc->auth);
monc->pending_auth = 0;
ret = ceph_handle_auth_reply(monc->auth, msg->front.iov_base,
msg->front.iov_len,
monc->m_auth->front.iov_base,
monc->m_auth->front_alloc_len);
if (ret > 0) {
__send_prepared_auth_request(monc, ret);
goto out;
}
finish_hunting(monc);
if (ret < 0) {
monc->client->auth_err = ret;
} else if (!was_auth && ceph_auth_is_authenticated(monc->auth)) {
struct ceph_messenger *msgr = &monc->client->msgr;
dout("authenticated, starting session\n");
if (msgr->inst.name.type == CEPH_ENTITY_TYPE_CLIENT)
msgr->inst.name.num =
cpu_to_le64(monc->auth->global_id);
__send_subscribe(monc);
__resend_generic_request(monc);
pr_info("mon%d %s session established\n", monc->cur_mon,
ceph_pr_addr(&monc->con.peer_addr));
}
out:
mutex_unlock(&monc->mutex);
if (monc->client->auth_err < 0)
wake_up_all(&monc->client->auth_wq);
}
static int __validate_auth(struct ceph_mon_client *monc)
{
int ret;
if (monc->pending_auth)
return 0;
ret = ceph_build_auth(monc->auth, monc->m_auth->front.iov_base,
monc->m_auth->front_alloc_len);
if (ret <= 0)
return ret; /* either an error, or no need to authenticate */
__send_prepared_auth_request(monc, ret);
return 0;
}
int ceph_monc_validate_auth(struct ceph_mon_client *monc)
{
int ret;
mutex_lock(&monc->mutex);
ret = __validate_auth(monc);
mutex_unlock(&monc->mutex);
return ret;
}
EXPORT_SYMBOL(ceph_monc_validate_auth);
/*
* handle incoming message
*/
static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
{
struct ceph_mon_client *monc = con->private;
int type = le16_to_cpu(msg->hdr.type);
switch (type) {
case CEPH_MSG_AUTH_REPLY:
handle_auth_reply(monc, msg);
break;
case CEPH_MSG_MON_SUBSCRIBE_ACK:
handle_subscribe_ack(monc, msg);
break;
case CEPH_MSG_STATFS_REPLY:
handle_statfs_reply(monc, msg);
break;
case CEPH_MSG_MON_GET_VERSION_REPLY:
handle_get_version_reply(monc, msg);
break;
case CEPH_MSG_MON_COMMAND_ACK:
handle_command_ack(monc, msg);
break;
case CEPH_MSG_MON_MAP:
ceph_monc_handle_map(monc, msg);
break;
case CEPH_MSG_OSD_MAP:
ceph_osdc_handle_map(&monc->client->osdc, msg);
break;
default:
/* can the chained handler handle it? */
if (monc->client->extra_mon_dispatch &&
monc->client->extra_mon_dispatch(monc->client, msg) == 0)
break;
pr_err("received unknown message type %d %s\n", type,
ceph_msg_type_name(type));
}
ceph_msg_put(msg);
}
static void mon_complete_osd_marked_down(struct ceph_mon_client *monc)
{
mutex_lock(&monc->mutex);
complete_all(&monc->m_osd_marked_down_comp);
mutex_unlock(&monc->mutex);
}
/*
* Allocate memory for incoming message
*/
static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
struct ceph_msg_header *hdr,
int *skip)
{
struct ceph_mon_client *monc = con->private;
int type = le16_to_cpu(hdr->type);
int front_len = le32_to_cpu(hdr->front_len);
struct ceph_msg *m = NULL;
*skip = 0;
switch (type) {
case CEPH_MSG_MON_SUBSCRIBE_ACK:
m = ceph_msg_get(monc->m_subscribe_ack);
break;
case CEPH_MSG_STATFS_REPLY:
case CEPH_MSG_MON_COMMAND_ACK:
return get_generic_reply(con, hdr, skip);
case CEPH_MSG_OSD_MARK_ME_DOWN:
*skip = 1;
mon_complete_osd_marked_down(monc);
return NULL;
case CEPH_MSG_AUTH_REPLY:
m = ceph_msg_get(monc->m_auth_reply);
break;
case CEPH_MSG_MON_GET_VERSION_REPLY:
if (le64_to_cpu(hdr->tid) != 0)
return get_generic_reply(con, hdr, skip);
/*
* Older OSDs don't set reply tid even if the orignal
* request had a non-zero tid. Work around this weirdness
* by allocating a new message.
*/
/* fall through */
case CEPH_MSG_MON_MAP:
case CEPH_MSG_MDS_MAP:
case CEPH_MSG_OSD_MAP:
case CEPH_MSG_FS_MAP_USER:
m = ceph_msg_new(type, front_len, GFP_NOFS, false);
if (!m)
return NULL; /* ENOMEM--return skip == 0 */
break;
}
if (!m) {
pr_info("alloc_msg unknown type %d\n", type);
*skip = 1;
} else if (front_len > m->front_alloc_len) {
pr_warn("mon_alloc_msg front %d > prealloc %d (%u#%llu)\n",
front_len, m->front_alloc_len,
(unsigned int)con->peer_name.type,
le64_to_cpu(con->peer_name.num));
ceph_msg_put(m);
m = ceph_msg_new(type, front_len, GFP_NOFS, false);
}
return m;
}
/*
* If the monitor connection resets, pick a new monitor and resubmit
* any pending requests.
*/
static void mon_fault(struct ceph_connection *con)
{
struct ceph_mon_client *monc = con->private;
mutex_lock(&monc->mutex);
dout("%s mon%d\n", __func__, monc->cur_mon);
if (monc->cur_mon >= 0) {
if (!monc->hunting) {
dout("%s hunting for new mon\n", __func__);
reopen_session(monc);
__schedule_delayed(monc);
} else {
dout("%s already hunting\n", __func__);
}
}
mutex_unlock(&monc->mutex);
}
/*
* We can ignore refcounting on the connection struct, as all references
* will come from the messenger workqueue, which is drained prior to
* mon_client destruction.
*/
static struct ceph_connection *con_get(struct ceph_connection *con)
{
return con;
}
static void con_put(struct ceph_connection *con)
{
}
static const struct ceph_connection_operations mon_con_ops = {
.get = con_get,
.put = con_put,
.dispatch = dispatch,
.fault = mon_fault,
.alloc_msg = mon_alloc_msg,
};
| [
"rpenyaev@suse.de"
] | rpenyaev@suse.de |
815b2300fe2038fcda1fc18adc04992740d79073 | 283a79eb39fea7e8bbc166f32c8e1fe095c564fb | /serial_mult.c | 7f09c9f6cdc4688e9321dd5b1638d2c413b39e88 | [] | no_license | RaulVargasNavarro/MPI | 6f6a1cd0c80caf7f649de80bd935c61e7f3b2a8e | c1258423af03529e7eb48fde3ed14b395d1d714d | refs/heads/master | 2021-01-12T11:03:15.001193 | 2016-11-04T02:24:39 | 2016-11-04T02:24:39 | 72,805,924 | 1 | 1 | null | null | null | null | UTF-8 | C | false | false | 1,868 | c | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
void ReadMatrix(FILE *fp,double **A,int m,int n)
{
int i,j;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
fscanf(fp,"%lf",&A[i][j]);
}
}
}
void WriteMatrix(FILE *fp,double **A,int m,int n)
{
int i,j;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
fprintf(fp,"%lf ",A[i][j]);
}
fprintf(fp,"\n");
}
}
int main(int argc, char *argv[])
{
int i,j,k;
FILE *fpa,*fpb,*fpc;
int m,n;
char *file_A,*file_B,*file_C;
double **A, **B, **C;
if (argc < 6)
{
printf("%s usage : nrows ncolums file_name_Matrix_A file_name_Matrix_B file_name_Matrix_C \n",argv[0]);
return(1);
}
m=atoi(argv[1]);
n=atoi(argv[2]);
file_A=argv[3];
file_B=argv[4];
file_C=argv[5];
fpa=fopen(file_A,"r");
fpb=fopen(file_B,"r");
fpc=fopen(file_C,"w");
if ( fpa == NULL || fpb == NULL || fpc == NULL)
{
printf("problem opening file(s)....\n");
fclose(fpa);
fclose(fpb);
fclose(fpc);
return(1);
}
A=malloc(m*sizeof(double *));
B=malloc(m*sizeof(double *));
C=malloc(m*sizeof(double *));
if (A==NULL || B==NULL || C== NULL)
{
printf("problem with malloc...\n");
free(A);
free(B);
free(C);
fclose(fpa);
fclose(fpb);
fclose(fpc);
return(1);
}
for(i=0;i<m;i++)
{
A[i]=malloc(n*sizeof(double));
B[i]=malloc(n*sizeof(double));
C[i]=malloc(n*sizeof(double));
}
ReadMatrix(fpa,A,m,n);
ReadMatrix(fpb,B,m,n);
clock_t tic =clock();
for (i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
C[i][j]=0.0;
for(k=0;k<m;k++)
{
C[i][j]=C[i][j]+A[i][k]*B[k][j];
}
}
}
clock_t toc =clock();
printf("Time in seconds : %lf\n",(double)(toc-tic)/(double)CLOCKS_PER_SEC);
WriteMatrix(fpc,C,m,n);
fclose(fpa);
fclose(fpb);
fclose(fpc);
return (0);
}
| [
"noreply@github.com"
] | RaulVargasNavarro.noreply@github.com |
94e1b121fb476ebdd02ad540ff522d249c167766 | 9922d68965c40d28a68a517c3e1b847f540ff2b8 | /01.11/20210111_6.c | 4cd4381851d51e9b9384505c297b81bb03ecd079 | [] | no_license | IIPanchev/Code-Academy | d08a86a7c6331ce11a52f4c3c8d583654e2bcaaa | f5fa4ba9955a0ffdae57ea573c1edd2a03bbb57e | refs/heads/main | 2023-02-17T19:58:35.734758 | 2021-01-14T11:47:35 | 2021-01-14T11:47:35 | 326,518,538 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 143 | c | #include <stdio.h>
int main(){
int a = 73;
int in = 4;
int M = 1<<in;
a = a^M;
printf("%d \n", a);
return 0;
} | [
"ignat.panchev@gmail.com"
] | ignat.panchev@gmail.com |
c5df8c7502d2dc73cc585a8503592f3f2997933e | 751d837b8a4445877bb2f0d1e97ce41cd39ce1bd | /dailyprogrammer/228-easy-letters-in-alphabetical-order.c | ad933728c9f3005368b15569e91b2234ad169a8f | [
"MIT"
] | permissive | qeedquan/challenges | d55146f784a3619caa4541ac6f2b670b0a3dd8ba | 56823e77cf502bdea68cce0e1221f5add3d64d6a | refs/heads/master | 2023-08-11T20:35:09.726571 | 2023-08-11T13:02:43 | 2023-08-11T13:02:43 | 115,886,967 | 2 | 1 | null | null | null | null | UTF-8 | C | false | false | 2,163 | c | /*
Description
A handful of words have their letters in alphabetical order, that is nowhere in the word do you change direction in the word if you were to scan along the English alphabet.
An example is the word "almost", which has its letters in alphabetical order.
Your challenge today is to write a program that can determine if the letters in a word are in alphabetical order.
As a bonus, see if you can find words spelled in reverse alphebatical order.
Input Description
You'll be given one word per line, all in standard English. Examples:
almost
cereal
Output Description
Your program should emit the word and if it is in order or not. Examples:
almost IN ORDER
cereal NOT IN ORDER
Challenge Input
billowy
biopsy
chinos
defaced
chintz
sponged
bijoux
abhors
fiddle
begins
chimps
wronged
Challenge Output
billowy IN ORDER
biopsy IN ORDER
chinos IN ORDER
defaced NOT IN ORDER
chintz IN ORDER
sponged REVERSE ORDER
bijoux IN ORDER
abhors IN ORDER
fiddle NOT IN ORDER
begins IN ORDER
chimps IN ORDER
wronged REVERSE ORDER
*/
#include <assert.h>
#include <stdio.h>
#include <string.h>
char *
classify(const char *s, char *b)
{
size_t i;
int f;
f = 0;
for (i = 0; s[i] && s[i + 1] && f != 3; i++) {
if (s[i] <= s[i + 1])
f |= 1;
else if (s[i] > s[i + 1])
f |= 2;
}
switch (f) {
case 0:
case 1:
sprintf(b, "%s IN ORDER", s);
break;
case 2:
sprintf(b, "%s REVERSE ORDER", s);
break;
case 3:
sprintf(b, "%s NOT IN ORDER", s);
break;
}
return b;
}
void
test(const char *s, const char *r)
{
char b[128];
classify(s, b);
assert(!strcmp(b, r));
}
int
main(void)
{
test("almost", "almost IN ORDER");
test("cereal", "cereal NOT IN ORDER");
test("billowy", "billowy IN ORDER");
test("biopsy", "biopsy IN ORDER");
test("chinos", "chinos IN ORDER");
test("defaced", "defaced NOT IN ORDER");
test("chintz", "chintz IN ORDER");
test("sponged", "sponged REVERSE ORDER");
test("bijoux", "bijoux IN ORDER");
test("abhors", "abhors IN ORDER");
test("fiddle", "fiddle NOT IN ORDER");
test("begins", "begins IN ORDER");
test("chimps", "chimps IN ORDER");
test("wronged", "wronged REVERSE ORDER");
return 0;
}
| [
"qeed.quan@gmail.com"
] | qeed.quan@gmail.com |
dff73e2834db58d981592841c4c6ea752353335c | ac047925550c0fedd2e0ec10f9552cdedc450ab4 | /fft.c | 960ea781f559a37eb6fbb97f6f423eb7b271a903 | [] | no_license | ailiev/fft-cilk | ba77bed4b38d999dd32b384696d277962804b282 | 9b7a750ae3df923d22934dd7906d673a3f36e419 | refs/heads/master | 2021-01-19T08:15:41.761902 | 2010-12-25T19:26:23 | 2010-12-25T19:26:23 | 1,197,287 | 1 | 1 | null | null | null | null | UTF-8 | C | false | false | 8 | c | fft.cilk | [
"alex.iliev@gmail.com"
] | alex.iliev@gmail.com |
dee62f999406104a0d6818900d94de4e156ef926 | 43972ecf7cd1ba255183276fe45f166eb8b6e54f | /C/Introduction/sumOfDifferences.C | 1a3106b50f844f3f518a9a707969a3d6b483ce7c | [] | no_license | JakeLearman/Hackerrank | a8ea98f7d99747da9fc5b959608b9bbbf1b70522 | cac829863fedb90f855bab114e4da12ecb9c2b76 | refs/heads/master | 2020-04-13T05:52:26.043626 | 2019-01-28T09:27:00 | 2019-01-28T09:27:00 | 163,005,694 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 398 | c | #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int int1;
int int2;
float f1;
float f2;
scanf("%d %d", &int1,& int2);
scanf("%f %f", &f1, &f2);
int iSum = int1 + int2;
int iDiff = int1 - int2;
float fSum = f1 + f2;
float fDiff = f1 - f2;
printf("%d %d\n%0.1f %0.1f", iSum, iDiff, fSum, fDiff);
return 0;
}
| [
"jaken_learman@hotmail.com"
] | jaken_learman@hotmail.com |
fb995b736bf35f5aa19d8739850f5bd67449d66f | a8d160d64cf9862663c2ec8456ff98088fd1ce5e | /src/drivers/tty/n_tty_disc.c | 26df8aadf9078373a2edb82dd681043c57ab3c32 | [
"MIT"
] | permissive | mirmik/kernel | 0aac0bfc2177fd9947da9c19c41a3fe5f580101c | e49a1a3e77c848aca035da16bc818783ea26acb4 | refs/heads/master | 2023-02-17T04:16:56.196724 | 2021-01-19T15:38:21 | 2021-01-19T15:38:21 | 296,941,859 | 1 | 0 | null | null | null | null | UTF-8 | C | false | false | 120 | c | #include <drivers/tty/n_tty_ldisc.h>
struct tty_ldisc_operations tty_ldisc =
{
n_tty_read,
n_tty_newchar
};
void
| [
"mirmikns@yandex.ru"
] | mirmikns@yandex.ru |
2d2c945bcab3a3ce654f39b5ce4a98fc9fed1670 | d20ec5a5b0f35a203e4d31633079d5fc58a00f84 | /joins/hashJoin_gpu/other/memset_hash/tuple.h | c6088ed0a3eb09f78a5cf6457913399736a208f6 | [] | no_license | yabuta/eating_one | f803147e1b12922960d39d48a9272b216015cb96 | 582d587d196c12443f8ca0bc74b5f25194ff1ca2 | refs/heads/master | 2020-12-24T19:27:02.151563 | 2016-03-08T13:29:25 | 2016-03-08T13:29:25 | 16,757,781 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 4,686 | h | #define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 4096 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 256 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 100000000 //val selectivity is 1/SELECTIVITY
#define RES_MAX 1000000
#define MATCH_RATE 10
/*1048576 * 1048576
#define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 512 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 64 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 250000 //val selectivity is 1/SELECTIVITY
*/
/* 4194304 * 4194304
#define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 2048 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 128 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 100000000 //val selectivity is 1/SELECTIVITY
#define RES_MAX 1000000
*/
/* optimatic values 10000000 10000000
#define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 4096 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 256 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 100000000 //val selectivity is 1/SELECTIVITY
#define RES_MAX 1000000
*/
/* parallelism optimate
#define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 8192 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 64 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 169000000 //val selectivity is 1/SELECTIVITY
*/
/*50000000 * 50000000 opt
#define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 65536 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 256 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 169000000 //val selectivity is 1/SELECTIVITY
#define RES_MAX 1000000
*/
/* 16777216 * 16777216
#define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 8192 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 128 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 100000000 //val selectivity is 1/SELECTIVITY
#define RES_MAX 1000000
*/
/* 67108864 * 67108864
#define BLOCK_SIZE_X 1024 //cuda block size of join and count kernel
#define BLOCK_SIZE_Y 1
#define GRID_SIZE_Y 1
#define PART_C_NUM 256 //cuda block size of hash partition count
#define PER_TH 65536 //the number of tuple per one thread of hash partition
#define B_ROW_NUM 256 //the number of sub left tuple per one block in join and count kernel
#define J_T_LEFT B_ROW_NUM/GRID_SIZE_Y
#define JT_SIZE 120000000 //max result tuple size
#define SELECTIVITY 169000000 //val selectivity is 1/SELECTIVITY
#define RES_MAX 1000000
*/
typedef struct _TUPLE {
int key;
int val;
} TUPLE;
typedef struct _RESULT {
int rkey;
int rval;
int lkey;
int lval;
} RESULT;
//#define TUPLE_SIZE 8
//#define SHAREDSIZE 49152
| [
"yabuta@hpc4.ertl.jp"
] | yabuta@hpc4.ertl.jp |
646e1bce4918037fa86d7324531f0ba1c54d7c39 | e80e5374b8fd00379293adb35fc8cf017d5f4cc7 | /qemu_mode/qemu-2.10.0/tests/bios-tables-test.c | 564da45f659594fdffb29120d56bbdd42ff909b3 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"GPL-2.0-only",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"LGPL-2.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | CAFA1/afl | dcebf3a3acae3e9783bbb79d8cff6958b496fa34 | 01c113b61ab70c3b02f3d7c74e6dfa20cfc7813d | refs/heads/master | 2023-04-10T14:30:34.901666 | 2020-07-27T01:06:32 | 2020-07-27T01:06:32 | 272,596,630 | 0 | 2 | Apache-2.0 | 2021-04-15T00:56:55 | 2020-06-16T03:03:26 | C | UTF-8 | C | false | false | 26,745 | c | /*
* Boot order test cases.
*
* Copyright (c) 2013 Red Hat Inc.
*
* Authors:
* Michael S. Tsirkin <mst@redhat.com>,
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
#include <glib/gstdio.h>
#include "qemu-common.h"
#include "hw/smbios/smbios.h"
#include "qemu/bitmap.h"
#include "acpi-utils.h"
#include "boot-sector.h"
#define MACHINE_PC "pc"
#define MACHINE_Q35 "q35"
#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
typedef struct {
const char *machine;
const char *variant;
uint32_t rsdp_addr;
AcpiRsdpDescriptor rsdp_table;
AcpiRsdtDescriptorRev1 rsdt_table;
AcpiFadtDescriptorRev3 fadt_table;
AcpiFacsDescriptorRev1 facs_table;
uint32_t *rsdt_tables_addr;
int rsdt_tables_nr;
GArray *tables;
uint32_t smbios_ep_addr;
struct smbios_21_entry_point smbios_ep_table;
uint8_t *required_struct_types;
int required_struct_types_len;
} test_data;
static char disk[] = "tests/acpi-test-disk-XXXXXX";
static const char *data_dir = "tests/acpi-test-data";
#ifdef CONFIG_IASL
static const char *iasl = stringify(CONFIG_IASL);
#else
static const char *iasl;
#endif
static void free_test_data(test_data *data)
{
AcpiSdtTable *temp;
int i;
g_free(data->rsdt_tables_addr);
for (i = 0; i < data->tables->len; ++i) {
temp = &g_array_index(data->tables, AcpiSdtTable, i);
g_free(temp->aml);
if (temp->aml_file &&
!temp->tmp_files_retain &&
g_strstr_len(temp->aml_file, -1, "aml-")) {
unlink(temp->aml_file);
}
g_free(temp->aml_file);
g_free(temp->asl);
if (temp->asl_file &&
!temp->tmp_files_retain) {
unlink(temp->asl_file);
}
g_free(temp->asl_file);
}
g_array_free(data->tables, true);
}
static void test_acpi_rsdp_address(test_data *data)
{
uint32_t off = acpi_find_rsdp_address();
g_assert_cmphex(off, <, 0x100000);
data->rsdp_addr = off;
}
static void test_acpi_rsdp_table(test_data *data)
{
AcpiRsdpDescriptor *rsdp_table = &data->rsdp_table;
uint32_t addr = data->rsdp_addr;
acpi_parse_rsdp_table(addr, rsdp_table);
/* rsdp checksum is not for the whole table, but for the first 20 bytes */
g_assert(!acpi_calc_checksum((uint8_t *)rsdp_table, 20));
}
static void test_acpi_rsdt_table(test_data *data)
{
AcpiRsdtDescriptorRev1 *rsdt_table = &data->rsdt_table;
uint32_t addr = data->rsdp_table.rsdt_physical_address;
uint32_t *tables;
int tables_nr;
uint8_t checksum;
/* read the header */
ACPI_READ_TABLE_HEADER(rsdt_table, addr);
ACPI_ASSERT_CMP(rsdt_table->signature, "RSDT");
/* compute the table entries in rsdt */
tables_nr = (rsdt_table->length - sizeof(AcpiRsdtDescriptorRev1)) /
sizeof(uint32_t);
g_assert(tables_nr > 0);
/* get the addresses of the tables pointed by rsdt */
tables = g_new0(uint32_t, tables_nr);
ACPI_READ_ARRAY_PTR(tables, tables_nr, addr);
checksum = acpi_calc_checksum((uint8_t *)rsdt_table, rsdt_table->length) +
acpi_calc_checksum((uint8_t *)tables,
tables_nr * sizeof(uint32_t));
g_assert(!checksum);
/* SSDT tables after FADT */
data->rsdt_tables_addr = tables;
data->rsdt_tables_nr = tables_nr;
}
static void test_acpi_fadt_table(test_data *data)
{
AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table;
uint32_t addr;
/* FADT table comes first */
addr = data->rsdt_tables_addr[0];
ACPI_READ_TABLE_HEADER(fadt_table, addr);
ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr);
ACPI_READ_FIELD(fadt_table->dsdt, addr);
ACPI_READ_FIELD(fadt_table->model, addr);
ACPI_READ_FIELD(fadt_table->reserved1, addr);
ACPI_READ_FIELD(fadt_table->sci_int, addr);
ACPI_READ_FIELD(fadt_table->smi_cmd, addr);
ACPI_READ_FIELD(fadt_table->acpi_enable, addr);
ACPI_READ_FIELD(fadt_table->acpi_disable, addr);
ACPI_READ_FIELD(fadt_table->S4bios_req, addr);
ACPI_READ_FIELD(fadt_table->reserved2, addr);
ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk, addr);
ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr);
ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr);
ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr);
ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr);
ACPI_READ_FIELD(fadt_table->gpe1_base, addr);
ACPI_READ_FIELD(fadt_table->reserved3, addr);
ACPI_READ_FIELD(fadt_table->plvl2_lat, addr);
ACPI_READ_FIELD(fadt_table->plvl3_lat, addr);
ACPI_READ_FIELD(fadt_table->flush_size, addr);
ACPI_READ_FIELD(fadt_table->flush_stride, addr);
ACPI_READ_FIELD(fadt_table->duty_offset, addr);
ACPI_READ_FIELD(fadt_table->duty_width, addr);
ACPI_READ_FIELD(fadt_table->day_alrm, addr);
ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
ACPI_READ_FIELD(fadt_table->century, addr);
ACPI_READ_FIELD(fadt_table->boot_flags, addr);
ACPI_READ_FIELD(fadt_table->reserved, addr);
ACPI_READ_FIELD(fadt_table->flags, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->reset_register, addr);
ACPI_READ_FIELD(fadt_table->reset_value, addr);
ACPI_READ_FIELD(fadt_table->arm_boot_flags, addr);
ACPI_READ_FIELD(fadt_table->minor_revision, addr);
ACPI_READ_FIELD(fadt_table->x_facs, addr);
ACPI_READ_FIELD(fadt_table->x_dsdt, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_event_block, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_event_block, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_control_block, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_control_block, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm2_control_block, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm_timer_block, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe0_block, addr);
ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe1_block, addr);
ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
}
static void test_acpi_facs_table(test_data *data)
{
AcpiFacsDescriptorRev1 *facs_table = &data->facs_table;
uint32_t addr = data->fadt_table.firmware_ctrl;
ACPI_READ_FIELD(facs_table->signature, addr);
ACPI_READ_FIELD(facs_table->length, addr);
ACPI_READ_FIELD(facs_table->hardware_signature, addr);
ACPI_READ_FIELD(facs_table->firmware_waking_vector, addr);
ACPI_READ_FIELD(facs_table->global_lock, addr);
ACPI_READ_FIELD(facs_table->flags, addr);
ACPI_READ_ARRAY(facs_table->resverved3, addr);
ACPI_ASSERT_CMP(facs_table->signature, "FACS");
}
static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
{
uint8_t checksum;
ACPI_READ_TABLE_HEADER(&sdt_table->header, addr);
sdt_table->aml_len = sdt_table->header.length - sizeof(AcpiTableHeader);
sdt_table->aml = g_malloc0(sdt_table->aml_len);
ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
checksum = acpi_calc_checksum((uint8_t *)sdt_table,
sizeof(AcpiTableHeader)) +
acpi_calc_checksum((uint8_t *)sdt_table->aml,
sdt_table->aml_len);
g_assert(!checksum);
}
static void test_acpi_dsdt_table(test_data *data)
{
AcpiSdtTable dsdt_table;
uint32_t addr = data->fadt_table.dsdt;
memset(&dsdt_table, 0, sizeof(dsdt_table));
data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
test_dst_table(&dsdt_table, addr);
ACPI_ASSERT_CMP(dsdt_table.header.signature, "DSDT");
/* Place DSDT first */
g_array_append_val(data->tables, dsdt_table);
}
static void test_acpi_tables(test_data *data)
{
int tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */
int i;
for (i = 0; i < tables_nr; i++) {
AcpiSdtTable ssdt_table;
memset(&ssdt_table, 0, sizeof(ssdt_table));
uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
test_dst_table(&ssdt_table, addr);
g_array_append_val(data->tables, ssdt_table);
}
}
static void dump_aml_files(test_data *data, bool rebuild)
{
AcpiSdtTable *sdt;
GError *error = NULL;
gchar *aml_file = NULL;
gint fd;
ssize_t ret;
int i;
for (i = 0; i < data->tables->len; ++i) {
const char *ext = data->variant ? data->variant : "";
sdt = &g_array_index(data->tables, AcpiSdtTable, i);
g_assert(sdt->aml);
if (rebuild) {
uint32_t signature = cpu_to_le32(sdt->header.signature);
aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
(gchar *)&signature, ext);
fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
} else {
fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
g_assert_no_error(error);
}
g_assert(fd >= 0);
ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader));
g_assert(ret == sizeof(AcpiTableHeader));
ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
g_assert(ret == sdt->aml_len);
close(fd);
g_free(aml_file);
}
}
static bool compare_signature(AcpiSdtTable *sdt, const char *signature)
{
return !memcmp(&sdt->header.signature, signature, 4);
}
static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
{
AcpiSdtTable *temp;
GError *error = NULL;
GString *command_line = g_string_new(iasl);
gint fd;
gchar *out, *out_err;
gboolean ret;
int i;
fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
g_assert_no_error(error);
close(fd);
/* build command line */
g_string_append_printf(command_line, " -p %s ", sdt->asl_file);
if (compare_signature(sdt, "DSDT") ||
compare_signature(sdt, "SSDT")) {
for (i = 0; i < sdts->len; ++i) {
temp = &g_array_index(sdts, AcpiSdtTable, i);
if (compare_signature(temp, "DSDT") ||
compare_signature(temp, "SSDT")) {
g_string_append_printf(command_line, "-e %s ", temp->aml_file);
}
}
}
g_string_append_printf(command_line, "-d %s", sdt->aml_file);
/* pass 'out' and 'out_err' in order to be redirected */
ret = g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
g_assert_no_error(error);
if (ret) {
ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
&sdt->asl_len, &error);
g_assert(ret);
g_assert_no_error(error);
ret = (sdt->asl_len > 0);
}
g_free(out);
g_free(out_err);
g_string_free(command_line, true);
return !ret;
}
#define COMMENT_END "*/"
#define DEF_BLOCK "DefinitionBlock ("
#define BLOCK_NAME_END ","
static GString *normalize_asl(gchar *asl_code)
{
GString *asl = g_string_new(asl_code);
gchar *comment, *block_name;
/* strip comments (different generation days) */
comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
if (comment) {
comment += strlen(COMMENT_END);
while (*comment == '\n') {
comment++;
}
asl = g_string_erase(asl, 0, comment - asl->str);
}
/* strip def block name (it has file path in it) */
if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
g_assert(block_name);
asl = g_string_erase(asl, 0,
block_name + sizeof(BLOCK_NAME_END) - asl->str);
}
return asl;
}
static GArray *load_expected_aml(test_data *data)
{
int i;
AcpiSdtTable *sdt;
GError *error = NULL;
gboolean ret;
GArray *exp_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
for (i = 0; i < data->tables->len; ++i) {
AcpiSdtTable exp_sdt;
uint32_t signature;
gchar *aml_file = NULL;
const char *ext = data->variant ? data->variant : "";
sdt = &g_array_index(data->tables, AcpiSdtTable, i);
memset(&exp_sdt, 0, sizeof(exp_sdt));
exp_sdt.header.signature = sdt->header.signature;
signature = cpu_to_le32(sdt->header.signature);
try_again:
aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
(gchar *)&signature, ext);
if (getenv("V")) {
fprintf(stderr, "\nLooking for expected file '%s'\n", aml_file);
}
if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) {
exp_sdt.aml_file = aml_file;
} else if (*ext != '\0') {
/* try fallback to generic (extention less) expected file */
ext = "";
g_free(aml_file);
goto try_again;
}
g_assert(exp_sdt.aml_file);
if (getenv("V")) {
fprintf(stderr, "\nUsing expected file '%s'\n", aml_file);
}
ret = g_file_get_contents(aml_file, &exp_sdt.aml,
&exp_sdt.aml_len, &error);
g_assert(ret);
g_assert_no_error(error);
g_assert(exp_sdt.aml);
g_assert(exp_sdt.aml_len);
g_array_append_val(exp_tables, exp_sdt);
}
return exp_tables;
}
static void test_acpi_asl(test_data *data)
{
int i;
AcpiSdtTable *sdt, *exp_sdt;
test_data exp_data;
gboolean exp_err, err;
memset(&exp_data, 0, sizeof(exp_data));
exp_data.tables = load_expected_aml(data);
dump_aml_files(data, false);
for (i = 0; i < data->tables->len; ++i) {
GString *asl, *exp_asl;
sdt = &g_array_index(data->tables, AcpiSdtTable, i);
exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i);
err = load_asl(data->tables, sdt);
asl = normalize_asl(sdt->asl);
exp_err = load_asl(exp_data.tables, exp_sdt);
exp_asl = normalize_asl(exp_sdt->asl);
/* TODO: check for warnings */
g_assert(!err || exp_err);
if (g_strcmp0(asl->str, exp_asl->str)) {
if (exp_err) {
fprintf(stderr,
"Warning! iasl couldn't parse the expected aml\n");
} else {
uint32_t signature = cpu_to_le32(exp_sdt->header.signature);
sdt->tmp_files_retain = true;
exp_sdt->tmp_files_retain = true;
fprintf(stderr,
"acpi-test: Warning! %.4s mismatch. "
"Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
(gchar *)&signature,
sdt->asl_file, sdt->aml_file,
exp_sdt->asl_file, exp_sdt->aml_file);
if (getenv("V")) {
const char *diff_cmd = getenv("DIFF");
if (diff_cmd) {
int ret G_GNUC_UNUSED;
char *diff = g_strdup_printf("%s %s %s", diff_cmd,
exp_sdt->asl_file, sdt->asl_file);
ret = system(diff) ;
g_free(diff);
} else {
fprintf(stderr, "acpi-test: Warning. not showing "
"difference since no diff utility is specified. "
"Set 'DIFF' environment variable to a preferred "
"diff utility and run 'make V=1 check' again to "
"see ASL difference.");
}
}
}
}
g_string_free(asl, true);
g_string_free(exp_asl, true);
}
free_test_data(&exp_data);
}
static bool smbios_ep_table_ok(test_data *data)
{
struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
uint32_t addr = data->smbios_ep_addr;
ACPI_READ_ARRAY(ep_table->anchor_string, addr);
if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
return false;
}
ACPI_READ_FIELD(ep_table->checksum, addr);
ACPI_READ_FIELD(ep_table->length, addr);
ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
ACPI_READ_FIELD(ep_table->smbios_minor_version, addr);
ACPI_READ_FIELD(ep_table->max_structure_size, addr);
ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
ACPI_READ_ARRAY(ep_table->formatted_area, addr);
ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
return false;
}
ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
ACPI_READ_FIELD(ep_table->structure_table_length, addr);
if (ep_table->structure_table_length == 0) {
return false;
}
ACPI_READ_FIELD(ep_table->structure_table_address, addr);
ACPI_READ_FIELD(ep_table->number_of_structures, addr);
if (ep_table->number_of_structures == 0) {
return false;
}
ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
acpi_calc_checksum((uint8_t *)ep_table + 0x10,
sizeof *ep_table - 0x10)) {
return false;
}
return true;
}
static void test_smbios_entry_point(test_data *data)
{
uint32_t off;
/* find smbios entry point structure */
for (off = 0xf0000; off < 0x100000; off += 0x10) {
uint8_t sig[] = "_SM_";
int i;
for (i = 0; i < sizeof sig - 1; ++i) {
sig[i] = readb(off + i);
}
if (!memcmp(sig, "_SM_", sizeof sig)) {
/* signature match, but is this a valid entry point? */
data->smbios_ep_addr = off;
if (smbios_ep_table_ok(data)) {
break;
}
}
}
g_assert_cmphex(off, <, 0x100000);
}
static inline bool smbios_single_instance(uint8_t type)
{
switch (type) {
case 0:
case 1:
case 2:
case 3:
case 16:
case 32:
case 127:
return true;
default:
return false;
}
}
static void test_smbios_structs(test_data *data)
{
DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) = { 0 };
struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
uint32_t addr = ep_table->structure_table_address;
int i, len, max_len = 0;
uint8_t type, prv, crt;
/* walk the smbios tables */
for (i = 0; i < ep_table->number_of_structures; i++) {
/* grab type and formatted area length from struct header */
type = readb(addr);
g_assert_cmpuint(type, <=, SMBIOS_MAX_TYPE);
len = readb(addr + 1);
/* single-instance structs must not have been encountered before */
if (smbios_single_instance(type)) {
g_assert(!test_bit(type, struct_bitmap));
}
set_bit(type, struct_bitmap);
/* seek to end of unformatted string area of this struct ("\0\0") */
prv = crt = 1;
while (prv || crt) {
prv = crt;
crt = readb(addr + len);
len++;
}
/* keep track of max. struct size */
if (max_len < len) {
max_len = len;
g_assert_cmpuint(max_len, <=, ep_table->max_structure_size);
}
/* start of next structure */
addr += len;
}
/* total table length and max struct size must match entry point values */
g_assert_cmpuint(ep_table->structure_table_length, ==,
addr - ep_table->structure_table_address);
g_assert_cmpuint(ep_table->max_structure_size, ==, max_len);
/* required struct types must all be present */
for (i = 0; i < data->required_struct_types_len; i++) {
g_assert(test_bit(data->required_struct_types[i], struct_bitmap));
}
}
static void test_acpi_one(const char *params, test_data *data)
{
char *args;
/* Disable kernel irqchip to be able to override apic irq0. */
args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
"-net none -display none %s "
"-drive id=hd0,if=none,file=%s,format=raw "
"-device ide-hd,drive=hd0 ",
data->machine, "kvm:tcg",
params ? params : "", disk);
qtest_start(args);
boot_sector_test();
test_acpi_rsdp_address(data);
test_acpi_rsdp_table(data);
test_acpi_rsdt_table(data);
test_acpi_fadt_table(data);
test_acpi_facs_table(data);
test_acpi_dsdt_table(data);
test_acpi_tables(data);
if (iasl) {
if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
dump_aml_files(data, true);
} else {
test_acpi_asl(data);
}
}
test_smbios_entry_point(data);
test_smbios_structs(data);
qtest_quit(global_qtest);
g_free(args);
}
static uint8_t base_required_struct_types[] = {
0, 1, 3, 4, 16, 17, 19, 32, 127
};
static void test_acpi_piix4_tcg(void)
{
test_data data;
/* Supplying -machine accel argument overrides the default (qtest).
* This is to make guest actually run.
*/
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.required_struct_types = base_required_struct_types;
data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one(NULL, &data);
free_test_data(&data);
}
static void test_acpi_piix4_tcg_bridge(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".bridge";
data.required_struct_types = base_required_struct_types;
data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one("-device pci-bridge,chassis_nr=1", &data);
free_test_data(&data);
}
static void test_acpi_q35_tcg(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.required_struct_types = base_required_struct_types;
data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one(NULL, &data);
free_test_data(&data);
}
static void test_acpi_q35_tcg_bridge(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".bridge";
data.required_struct_types = base_required_struct_types;
data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
test_acpi_one("-device pci-bridge,chassis_nr=1",
&data);
free_test_data(&data);
}
static void test_acpi_piix4_tcg_cphp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".cphp";
test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node"
" -numa dist,src=0,dst=1,val=21",
&data);
free_test_data(&data);
}
static void test_acpi_q35_tcg_cphp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".cphp";
test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
" -numa node -numa node"
" -numa dist,src=0,dst=1,val=21",
&data);
free_test_data(&data);
}
static uint8_t ipmi_required_struct_types[] = {
0, 1, 3, 4, 16, 17, 19, 32, 38, 127
};
static void test_acpi_q35_tcg_ipmi(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".ipmibt";
data.required_struct_types = ipmi_required_struct_types;
data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
" -device isa-ipmi-bt,bmc=bmc0",
&data);
free_test_data(&data);
}
static void test_acpi_piix4_tcg_ipmi(void)
{
test_data data;
/* Supplying -machine accel argument overrides the default (qtest).
* This is to make guest actually run.
*/
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".ipmikcs";
data.required_struct_types = ipmi_required_struct_types;
data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
" -device isa-ipmi-kcs,irq=0,bmc=bmc0",
&data);
free_test_data(&data);
}
static void test_acpi_q35_tcg_memhp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
data.variant = ".memhp";
test_acpi_one(" -m 128,slots=3,maxmem=1G"
" -numa node -numa node"
" -numa dist,src=0,dst=1,val=21",
&data);
free_test_data(&data);
}
static void test_acpi_piix4_tcg_memhp(void)
{
test_data data;
memset(&data, 0, sizeof(data));
data.machine = MACHINE_PC;
data.variant = ".memhp";
test_acpi_one(" -m 128,slots=3,maxmem=1G"
" -numa node -numa node"
" -numa dist,src=0,dst=1,val=21",
&data);
free_test_data(&data);
}
int main(int argc, char *argv[])
{
const char *arch = qtest_get_arch();
int ret;
ret = boot_sector_init(disk);
if(ret)
return ret;
g_test_init(&argc, &argv, NULL);
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
qtest_add_func("acpi/q35", test_acpi_q35_tcg);
qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
}
ret = g_test_run();
boot_sector_cleanup(disk);
return ret;
}
| [
"longlong_vm@dell_book.com"
] | longlong_vm@dell_book.com |
02a2c092eddccc1df739af812b15695152b3071d | 90c8a1d4c4e4108668ad4b2581918f327740599a | /libft/ft_strcmp.c | 115acc574269b8850848aae79411c2ef0e4b3cbf | [] | no_license | fanno42/FdF | 17f7971fbc175e7832e813b5aa961d7ea1fd96e2 | 427e513c12c96bc2b48bfbc242f14538ccdf165c | refs/heads/master | 2021-01-10T18:08:26.925006 | 2016-11-20T13:10:30 | 2016-11-20T13:10:30 | 71,905,216 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,075 | c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fanno <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/23 16:23:32 by fanno #+# #+# */
/* Updated: 2015/12/16 09:57:07 by fanno ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
while (*s1 || *s2)
if (*s1++ != *s2++)
return ((unsigned char)*--s1 - (unsigned char)*--s2);
return (0);
}
| [
"fanno@e1r8p11.42.fr"
] | fanno@e1r8p11.42.fr |
e648a1fb49831accfe6b10c4c6758e7dac673790 | dd592c85516836da68265579aa16a98b19f8d5bf | /src/proba.c | addddbc41ea316e4409742b792a39c4e6ee8f0bf | [] | no_license | khrengen/1stCourse | a7439ea7a4e1aee8966d0a7e582b06eb18e6f923 | 06c1c8e6288b14c0b5aa06d6a3608de98cab4771 | refs/heads/master | 2022-11-06T04:22:30.950308 | 2020-06-22T13:12:19 | 2020-06-22T13:12:19 | 274,139,940 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 158 | c | #include <stdio.h>
#include <math.h>
double func(double x)
{
return exp(x);
}
int main(void)
{
double x = func(2.0);
printf("%.3f", x);
} | [
"khrengen@gmail.com"
] | khrengen@gmail.com |
854643702036de81fef163fa513d9be1962528d9 | 9c3f5ec6383330ddbfd46842ef2abbaa9a52b1b6 | /C_Programming Total/April19Problems in C/192b.c | 3395db28f89e82be0f1858c27b4661215ab0f7c2 | [] | no_license | bkmcgee/C | 6fad2c4f1881bd9a14dc76de2d6285d27223f8a3 | 705f7330c9fa484fb8689a184948e65194cb251e | refs/heads/main | 2023-03-29T06:50:46.203959 | 2021-03-31T23:44:33 | 2021-03-31T23:44:33 | 353,519,071 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 2,007 | c | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
/////attempt 2 at April 19 question 2
typedef struct Complex
{
double real;
double imag;
} Complex;
Complex add(Complex a,Complex b)
{
Complex sum;
sum.real = a.real + b.real;
sum.imag = a.imag + b.imag;
return sum;
}
Complex sub(Complex a,Complex b)
{
Complex diff;
diff.real = a.real - b.real;
diff.imag = a.imag - b.imag;
return diff;
}
Complex conju(Complex a)
{
Complex temp;
temp.real = a.real;
temp.imag = -1*a.imag;
return temp;
}
Complex mult(Complex x, Complex y)
{
Complex mul;
mul.real = x.real * y.real- x.imag * y.imag;
mul.imag = x.real * y.imag + x.imag * y.real;
return mul;
}
Complex divide(Complex x,Complex y)
{
Complex z;
z.real = (x.real*y.real + x.imag*y.imag)/(y.real*y.real+y.imag*y.imag);
z.imag = (x.imag*y.real - x.real*y.imag)/(y.real*y.real + y.imag*y.imag);
return z;
}
double abso(Complex a)
{
double ans = pow(a.real*a.real+a.imag*a.imag,0.5);
return ans;
}
void print(Complex z)
{
char complex[20];
char real[10],imag[10];
snprintf(real, 10, "%lf", z.real);
snprintf(imag, 10, "%lf", z.imag);
if(z.imag>=0)
strcat(real,"+");
strcpy(complex,real);
strcat(complex,imag);
strcat(complex,"i");
printf("%s\n",complex);
}
///////////////main
int main()
{
Complex z,w;
printf("For 1st complex number \n");
printf("Enter real part : ");
scanf("%lf", &z.real);
printf("Enter imaginary part : ");
scanf("%lf", &z.imag);
printf("For 2nd complex number \n");
printf("Enter real part : ");
scanf("%lf", &w.real);
printf("Enter imaginary part : ");
scanf("%lf", &w.imag);
Complex res = add(z,w);
printf("z+w = ");
print(res);
printf("z-w = ");
res = sub(z,w);
print(res);
printf("zw = ");
res = mult(z,w);
print(res);
printf("z/w = ");
res = divide(z,w);
print(res);
printf("Conjugate of z = ");
res= conju(z);
print(res);
printf("Absolute value of z = %lf\n",abso(z));
return 0;////end
}
| [
"noreply@github.com"
] | bkmcgee.noreply@github.com |
687d26bda406bb67d3b2feff5257e78df52ba8e2 | 8c4f6f8bd51d5d0c1b1a08d77e2a4762a7b7f044 | /13_02_本地语言实现add/jni/ADD.c | bd46ae6c7ec47405d1594c7189f3a84391fe7f07 | [
"Apache-2.0"
] | permissive | dragonflyor/AndroidDemo_Base | 59d0afd8529981b2cfb26ce8e2f07ec167c12471 | 0662e69e04c41f651d39eaa811ed1dfac1910e6e | refs/heads/master | 2021-01-10T12:19:10.763404 | 2016-02-16T10:48:22 | 2016-02-16T10:48:22 | 51,759,944 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 126 | c | #include <jni.h>
jint Java_com_xiaozhe_localadd_MainActivity_add(JNIEnv * env, jobject obj, jint a, jint b)
{
return a+b;
}
| [
"1137176847@qq.com"
] | 1137176847@qq.com |
0efe487d75d65f4359df07cef922d8597ea16ef4 | d2cb92b877e0157092d8471c9ddf7aef06e28873 | /Pendu/main.c | 55023bd5edb204f1ecdc4821192d9cde1dcc5e65 | [] | no_license | Joktaa/Archives_C | a4f8144aa9a9111fce5d60ab3e3d1dd2db88efb0 | fb6011cefd0e8a7d1cca996819e4837a6302d668 | refs/heads/master | 2023-01-13T02:13:30.192618 | 2020-11-19T17:22:55 | 2020-11-19T17:22:55 | 314,319,965 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 5,712 | c | //idée : mode deux joueurs
#include <stdio.h>
#include <stdlib.h>
#include <time.h> //utilisation de srand
#include <ctype.h> // utilisation de toupper()
#include "module.h"
//PROTOTYPES
char lireCaractere();
void comp(char caractere, char motSecret[], char position[], char lenghtMotSecret);
int lenghtString(char motSecret[]);
int testComplete(char motSecret[], char motSecret2[], char lenghtMotSecret);
int nbrMot();
int randNbr(int a, int b);
int main(int argc, char const *argv[])
{
char caractere = 0; //stocke le caractere actuel saisi
char motSecret[100] = {0}; //stocke le mot secret
int lenghtMotSecret = 0; //stocke la longueur du mot secret
char *position = NULL; //pointeur sur position
char *motSecret2 = NULL; //pointeur sur le mot secret caché
int nbrCoup = 10; //stocke le nombre de coup disponible
int isComplete = 0; //stocke la reussite ou non du jeu
int fini = 0; //stovke la fin du jeu
int i = 0; //variable utile
FILE *fichier = NULL; //stocke le pointeur du fichier mot
int c = 0; //stocke un caractere
int nbrCrct = 0; //stocke le nombre de caractere d'ecart
int mot = 0; //stocke le nombre de mot d'ecart
int nbrHasard = 0; //stocke un nombre au hasard
int nbrMots = nbrMot(); //stocke le nombre de mot dans le fichier mot
nbrHasard = randNbr(0, (nbrMots - 2)); //choisis un nombre au hasard
fichier = fopen("mot.txt", "r"); //ouvre le fichier mot
//calcule le nombre de mot et de caractere entre le debut et le mot choisi
while(mot != nbrHasard)
{
c = fgetc(fichier);
if (c != '\n') {
nbrCrct++;
}
else
{
mot++;
}
}
fseek(fichier, (nbrCrct + nbrHasard * 2), SEEK_SET); //se positionne au bon mot dans le fichier
c = 0;
//rentre le mot choisi dans la chaine motSecret
while (c != '\n')
{
c = fgetc(fichier);
if (c != '\n')
{
motSecret[i] = c;
}
i++;
}
//lit le mot juste
/*i = 0;
while (c != '\0')
{
c = motSecret[i];
printf("%c", c);
i++;
}*/
fclose(fichier); //ferme le fichier
//creation du tableau position et motSecret2
lenghtMotSecret = lenghtString(motSecret);
position = malloc(sizeof(char)*lenghtMotSecret);
motSecret2 = malloc(sizeof(char)*lenghtMotSecret);
//initialisation de motSecret2
i = 0;
for(i = 0; i < lenghtMotSecret; i++)
{
motSecret2[i] = '*';
}
printf("BIENVENUE\n\n");
//compte a rebours
while(nbrCoup != 0 && fini == 0)
{
printf("\n\nIL VOUS RESTE %d ESSAIS\n", nbrCoup);
i = 0;
for (i = 0; i < lenghtMotSecret; i++)
{
printf("%c", motSecret2[i]);
}
printf("\nCHOISISSEZ UNE LETTRE : ");
int isJuste = 0; //variable stockant la justesse du caractere
caractere = lireCaractere(); //recupere la saisie
comp(caractere, motSecret, position, lenghtMotSecret); //compare
//revele les caracteres justes
int j = 0;
for(j = 0; j < lenghtMotSecret; j++)
{
if (position[j] == 1) {
motSecret2[j] = motSecret[j];
isJuste = 1;
}
}
//enleve un coup si aucun caractere juste
if (isJuste == 0) {
nbrCoup--;
}
//test le nombre de coup
if(nbrCoup == 0)
{
printf("DEFAITE");
exit(0);
}
isComplete = testComplete(motSecret, motSecret2, lenghtMotSecret);
if (isComplete == 1) {
fini = 1;
}
}
if (fini == 1) {
printf("\nBRAVO VOUS AVEZ GAGNE, LE MOT EST : ");
int k = 0;
for(k = 0; k < lenghtMotSecret; k++)
{
printf("%c", motSecret[k]);
}
exit(0);
}
return 0;
}
//fonction permettant de lire la saisie utilisateur
char lireCaractere()
{
char choix = 0;
choix = getchar();
choix = toupper(choix);
while(getchar() != '\n');
return choix;
}
//fonction permettant le caractere saisi et le mot secret
void comp(char caractere, char motSecret[], char position[], char lenghtMotSecret)
{
//remet position a 0
int j = 0;
for(j = 0 ; j < lenghtMotSecret ; j++)
{
position[j] = 0;
}
//compare
int i = 0;
for(i = 0 ; i < lenghtMotSecret ; i++){
if (motSecret[i] == caractere) {
position[i] = 1;
}
}
}
//fonction permettant de connaitre la longueur d'une chaine
int lenghtString(char motSecret[])
{
int i = 0;
while(motSecret[i] != '\0')
{
i++;
}
return i;
}
int testComplete(char motSecret[], char motSecret2[], char lenghtMotSecret)
{
int juste = 0;
int i = 0;
for(i = 0; i < lenghtMotSecret; i++)
{
if (motSecret[i] == motSecret2[i]) {
juste++;
}
}
if (juste == lenghtMotSecret) {
return 1;
}
else
{
return 0;
}
}
//compte le nombre de mot dans le fichier
int nbrMot()
{
FILE *fichier = NULL;
int c = 0;
int i = 1;
fichier = fopen("mot.txt", "r");
rewind(fichier);
while(c != EOF)
{
c = fgetc(fichier);
if (c == '\n') {
i++;
}
}
return i;
fclose(fichier);
}
//choisi un nombre au hasard entre a et b
int randNbr(int a, int b){
int nbr = 0;
int MIN = a;
int MAX = b;
srand(time(NULL));
nbr = (rand() % (MAX - MIN + 1) + MIN);
return nbr;
} | [
"joris.rouziere@gmail.com"
] | joris.rouziere@gmail.com |
3ef5acc8a0433ee059876660761bcdd99298a10f | ac45b5a1f9f357d14d7f290ff767d2bb849b657a | /src/scigl/shapes.h | 33f76388f568f037d8d686f6f127c4ac043d6f41 | [] | no_license | SimoneMSR/gentree | bbaf522c60fa7f030472112592eb2ce85e0b0654 | 12a12a02214f8bdae3f758485f39de28dad18375 | refs/heads/master | 2021-04-03T08:42:05.406362 | 2018-03-12T11:30:41 | 2018-03-12T11:30:41 | 124,876,722 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 2,085 | h | /*
* Copyright (C) 2008 Nicolas P. Rougier
*
* 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 3 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 __SHAPES_H__
#define __SHAPES_H__
#include "object.h"
#define SPH_RAD 0.01
#define TRI_H 0.01
#define QUAD_L 0.01
/**
* Sphere at (x,y,z)
*
* @param x center x coordinate
* @param y center y coordinate
* @param z center z coordinate
* @param r sphere radius
*/
void sphere (GLfloat x, GLfloat y, GLfloat z, GLfloat r);
/**
* Cylinder from (x1,y1,z1) to (x2,y2,z2)
*
* Based on the following implementation by Joel J. Parris:
* http://home.neo.rr.com/jparris/OpenGL - draw cylinder between 2 pts.htm
*
* @param x1 base x coordinate
* @param y1 base y coordinate
* @param z1 base z coordinate
* @param r1 base radius
* @param x2 top x coordinate
* @param y2 top y coordinate
* @param z2 top z coordinate
* @param r2 top radius
*/
void cylinder(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat r1,
GLfloat x2, GLfloat y2, GLfloat z2, GLfloat r2);
/**
* Unit-sized xy plane centered on 0 with optional grid
*
* @param fg
* @param bg
* @param nx
* @param ny
*/
void plane (Color fg, Color bg, int nx=0, int ny=0);
void triangle(GLfloat x1, GLfloat y1,
GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3);
void quad(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3,
GLfloat y3, GLfloat x4, GLfloat y4) ;
void polygon(GLfloat x, GLfloat y, int class_) ;
void switch_polygon(GLfloat x, GLfloat y, int polygon) ;
#endif
| [
"simonematteostefanoriccardo@gmail.com"
] | simonematteostefanoriccardo@gmail.com |
2af50c5adb038c9089287b3689ab6ff754b6178d | be49962ba4eccf3a0863e54aa43ba5d5034c1835 | /gameobjects.h | 59e335646273c7c2a83a21e277d247f5cbf1cf69 | [] | no_license | EdyJ/UnderworldExporter | 7efa0aa431de415855738dca0e5993448db03e4b | fd00d2e8b98f71f7d398e8053ec5a43784853ffc | refs/heads/master | 2021-01-21T02:45:01.200886 | 2014-03-27T21:51:19 | 2014-03-27T21:51:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 10,784 | h | #ifndef gameobjects_h
#define gameobjects_h
//Object types
//guessing at what I'll need at the moment
#define NPC 0
#define WEAPON 1
#define ARMOUR 2
#define AMMO 3
#define DOOR 4
#define KEY 5
#define RUNE 6
#define BRIDGE 7
#define BUTTON 8
#define LIGHT 9
#define SIGN 10
#define BOOK 11
#define WAND 12
#define SCROLL 13 //The reading kind
#define POTIONS 14
#define INSERTABLE 15 //Shock style put the circuit board in the slot.
#define INVENTORY 16 //Quest items and the like with no special properties
#define ACTIVATOR 17 //Crystal balls,magic fountains and surgery machines that have special custom effects when you activate them
#define TREASURE 18
#define CONTAINER 19
//#define TRAP 20
#define LOCK 21
#define TORCH 22
#define CLUTTER 23
#define FOOD 24
#define SCENERY 25
#define INSTRUMENT 26
#define FIRE 27
#define MAP 28
#define HIDDENDOOR 29
#define PORTCULLIS 30
#define PILLAR 31
#define SOUND 32
#define CORPSE 33
#define HIDDENPLACEHOLDER 34
#define TMAP_SOLID 34
#define TMAP_CLIP 35
#define MAGICSCROLL 36
#define A_DAMAGE_TRAP 37
#define A_TELEPORT_TRAP 38
#define A_ARROW_TRAP 39
#define A_DO_TRAP 40
#define A_PIT_TRAP 41
#define A_CHANGE_TERRAIN_TRAP 42
#define A_SPELLTRAP 43
#define A_CREATE_OBJECT_TRAP 44
#define A_DOOR_TRAP 45
#define A_WARD_TRAP 46
#define A_TELL_TRAP 47
#define A_DELETE_OBJECT_TRAP 48
#define AN_INVENTORY_TRAP 49
#define A_SET_VARIABLE_TRAP 50
#define A_CHECK_VARIABLE_TRAP 51
#define A_COMBINATION_TRAP 52
#define A_TEXT_STRING_TRAP 53
#define A_MOVE_TRIGGER 54
#define A_PICK_UP_TRIGGER 55
#define A_USE_TRIGGER 56
#define A_LOOK_TRIGGER 57
#define A_STEP_ON_TRIGGER 58
#define AN_OPEN_TRIGGER 59
#define AN_UNLOCK_TRIGGER 60
#define A_FOUNTAIN 61
#define SHOCK_DECAL 62
#define COMPUTER_SCREEN 63
/*SYSTEM SHOCK TRIGGER TYPES. I'm adding 100 to keep them seperate from the above*/
#define SHOCK_TRIGGER_ENTRY 100 //Player enters trigger's tile
#define SHOCK_TRIGGER_NULL 101 //Not set off automatically, must be explicitly activated by a switch or another trigger
#define SHOCK_TRIGGER_FLOOR 102
#define SHOCK_TRIGGER_PLAYER_DEATH 103
#define SHOCK_TRIGGER_DEATHWATCH 104 //Object is destroyed / dies
#define SHOCK_TRIGGER_AOE_ENTRY 105
#define SHOCK_TRIGGER_AOE_CONTINOUS 106
#define SHOCK_TRIGGER_AI_HINT 107
#define SHOCK_TRIGGER_LEVEL 108 //Player enters level
#define SHOCK_TRIGGER_CONTINUOUS 109
#define SHOCK_TRIGGER_REPULSOR 110 //Repulsor lift floor
#define SHOCK_TRIGGER_ECOLOGY 111
#define SHOCK_TRIGGER_SHODAN 112
#define SHOCK_TRIGGER_TRIPBEAM 113
#define SHOCK_TRIGGER_BIOHAZARD 114
#define SHOCK_TRIGGER_RADHAZARD 115
#define SHOCK_TRIGGER_CHEMHAZARD 116
#define SHOCK_TRIGGER_MAPNOTE 117 //Map note placed by player (presumably)
#define SHOCK_TRIGGER_MUSIC 118
//System Shock object classes
#define GUNS_WEAPONS 0
#define AMMUNITION 1
#define PROJECTILES 2
#define GRENADE_EXPLOSIONS 3
#define PATCHES 4
#define HARDWARE 5
#define SOFTWARE_LOGS 6
#define FIXTURES 7
#define GETTABLES_OTHER 8
#define SWITCHES_PANELS 9
#define DOORS_GRATINGS 10
#define ANIMATED 11
#define TRAPS_MARKERS 12
#define CONTAINERS_CORPSES 13
#define CRITTERS 14
//System Shock object classes offsets. For this I will use their chunk offset value.
#define GUNS_WEAPONS_OFFSET 4010
#define AMMUNITION_OFFSET 4011
#define PROJECTILES_OFFSET 4012
#define GRENADE_EXPLOSIONS_OFFSET 4013 //a guess
#define PATCHES_OFFSET 4014
#define HARDWARE_OFFSET 4015
#define SOFTWARE_LOGS_OFFSET 4016
#define FIXTURES_OFFSET 4017
#define GETTABLES_OTHER_OFFSET 4018 //a guess
#define SWITCHES_PANELS_OFFSET 4019
#define DOORS_GRATINGS_OFFSET 4020
#define ANIMATED_OFFSET 4021 //a guess?
#define TRAPS_MARKERS_OFFSET 4022
#define CONTAINERS_CORPSES_OFFSET 4023
#define CRITTERS_OFFSET 4043
/*SHOCK TRIGGER ACTION TYPES per ssspecs*/
#define ACTION_DO_NOTHING 0
#define ACTION_TRANSPORT_LEVEL 1
#define ACTION_RESURRECTION 2
#define ACTION_CLONE 3
#define ACTION_SET_VARIABLE 4
#define ACTION_ACTIVATE 6
#define ACTION_LIGHTING 7
#define ACTION_EFFECT 8
#define ACTION_MOVING_PLATFORM 9
#define ACTION_TIMER 11 //This is an assumption
#define ACTION_CHOICE 12
#define ACTION_EMAIL 15
#define ACTION_RADAWAY 16
#define ACTION_CHANGE_STATE 19
#define ACTION_MESSAGE 22
#define ACTION_SPAWN 23
#define ACTION_CHANGE_TYPE 24
/*Some friendly array indices for shock objProperties array*/
//Software
#define SOFT_PROPERTY_VERSION 0
#define SOFT_PROPERTY_LOG 9
#define SOFT_PROPERTY_LEVEL 2
//Buttons and panels
#define BUTTON_PROPERTY_TRIGGER 0
#define BUTTON_PROPERTY_PUZZLE 1
#define BUTTON_PROPERTY_COMBO 2
#define BUTTON_PROPERTY_TRIGGER_2 3
//Trigger props
#define TRIG_PROPERTY_OBJECT 0
#define TRIG_PROPERTY_TARGET_X 1
#define TRIG_PROPERTY_TARGET_Y 2
#define TRIG_PROPERTY_TARGET_Z 3
#define TRIG_PROPERTY_FLAG 4
#define TRIG_PROPERTY_VARIABLE 5
#define TRIG_PROPERTY_VALUE 6
#define TRIG_PROPERTY_OPERATION 7
#define TRIG_PROPERTY_MESSAGE1 8
#define TRIG_PROPERTY_MESSAGE2 9
#define TRIG_PROPERTY_CONTROL_1 4
#define TRIG_PROPERTY_CONTROL_2 5
#define TRIG_PROPERTY_UPPERSHADE_1 6
#define TRIG_PROPERTY_LOWERSHADE_1 7
#define TRIG_PROPERTY_UPPERSHADE_2 8
#define TRIG_PROPERTY_LOWERSHADE_2 9
#define TRIG_PROPERTY_FLOOR 5
#define TRIG_PROPERTY_CEILING 6
#define TRIG_PROPERTY_SPEED 7
#define TRIG_PROPERTY_TRIG_1 5
#define TRIG_PROPERTY_TRIG_2 6
#define TRIG_PROPERTY_EMAIL 9
#define TRIG_PROPERTY_TYPE 8
#define CONTAINER_CONTENTS_1 0
#define CONTAINER_CONTENTS_2 1
#define CONTAINER_CONTENTS_3 2
#define CONTAINER_CONTENTS_4 3
#define CONTAINER_WIDTH 5
#define CONTAINER_HEIGHT 6
#define CONTAINER_DEPTH 7
#define CONTAINER_TOP 8
#define CONTAINER_SIDE 9
#define SCREEN_NO_OF_FRAMES 0
#define SCREEN_LOOP_FLAG 1
#define SCREEN_START 2
//Master object type definition
struct ObjectItem
{
int index; //it's own index in case I need to find myself.
int item_id; //0-8
int flags; //9-12
short enchantment; //12
short doordir; //13
short invis; //14
short is_quant; //15
int texture; // Note: some objects don't have flags and use the whole lower byte as a texture number
//(gravestone, picture, lever, switch, shelf, bridge, ..)
int zpos; // 0- 6 7 "zpos" Object Z position (0-127)
int heading; // 7- 9 3 "heading" Heading (*45 deg)
int x; // 10-12 3 "ypos" Object Y position (0-7)
int y; // 13-15 3 "xpos" Object X position (0-7)
//0004 quality / chain
int quality; //; 0- 5 6 "quality" Quality
long next; // 6-15 10 "next" Index of next object in chain
//0006 link / special
// 0- 5 6 "owner" Owner / special
int owner; //Also special
// 6-15 10 (*) Quantity / special link / special property
int link ; //also quantity
//The values stored in the NPC info area (19 bytes) contain infos for
//critters unique to each object.
//0008
int npc_hp; //0-7
//0009
//blank?
//000a
//blank?
//000b Int16
short npc_goal; //0-3
short npc_gtarg; //4-11
//000d
short npc_level; //0-3
short npc_talkedto; //13
short npc_attitude; //14-15
//000f
short npc_height ;//6- 12 ?
//0016
short npc_yhome; // 4-9
short npc_xhome; // 10-15
//0018 0010 Int8 0-4: npc_heading?
// 0019 Int8 0-6:
short npc_hunger; //(?)
//001a 0012 Int8
int npc_whoami;
//Some stuff I need for attaching objects to joints.
int objectOwner; //index to the npc carrying the object
int objectOwnerName; //Npc whoami for
int objectOwnerEntity; //entity number that the owner was given during renderentity
short joint; //index to joint no.
short levelno;
short tileX; //Position of the object on the tilemap
short tileY;
//Shock specific stuff
short InUseFlag;
short ObjectClass;
short ObjectSubClass;
short ObjectSubClassIndex;
int Angle1;
int Angle2;
int Angle3;
int AIIndex;
int ObjectType;
int HitPoints;
int State;
//int duplicate; //when it extends into another tile
short TriggerOnce;
short TriggerAction; //For triggers
int shockProperties[10]; //Further generic properties for data pulled back from subclass blocks.
int conditions[4];
int sprite;
short unk1;
short SHOCKLocked;
short DeathWatched;
//scripting state flags
short global;
short TriggerOnceGlobal;
int objectConversion; //For what an object can turn into
short keyCount; //If this is a key then it needs to know which number of key it is.
};
struct objectMaster //For common object properties.
{
int index;
short type; //from above
char desc[80];
char path[80]; //to object model
short isEntity; // 1 for entity. 0 for model. -1 for ignored entries
short isSet;
short objClass; //For Shock
short objSubClass;
short objSubClassIndex;
short renderType;
short frame1; //Frame no
short DeathWatch;
};
//typedef struct shockObjectMaster
//{
//int index;
//int objClass;
//int objSubClass;
//int objSubClassIndex;
//char desc[80];
//}shockObjectMaster;
struct xrefTable
{
short tileX;// position
short tileY;// position
int next;
int MstIndex;// into master object table
int nextTile; //objects in next tile
short duplicate;
short duplicateAssigned;
short duplicateNextAssigned;
};
struct mstTable
{
int index;
int inuse;
short objectclass;
short objectsubclass;
short subclasslink;
int xRef;
int nextlink;
};
void EntityRotation(int heading);
void EntityRotationSHOCK(int heading);
void AttachToJoint(ObjectItem &currobj);
int isTrigger(ObjectItem currobj);
int isButton(ObjectItem currobj);
int isTrap(ObjectItem currobj);
int isLog (ObjectItem currobj);
int isContainer(ObjectItem currobj);
int hasContents(ObjectItem currobj);
long nextObject(ObjectItem &currObj);
//long nextObjectShock(shockObjectItem &currObj);
int isLock(ObjectItem currobj);
void createScriptCall(ObjectItem &currobj,float x,float y, float z);
void EntityRotation(int heading);
char *UniqueObjectName(ObjectItem currObj);
int isButtonSHOCK(ObjectItem currobj);
int isTriggerSHOCK(ObjectItem currobj);
char *getObjectNameByClass(int objClass, int subClass, int subClassIndex);
int getObjectIDByClass(int objClass, int subClass, int subClassIndex);
extern objectMaster *objectMasters;
//extern shockObjectMaster *shockObjectMasters;
#endif /*gameobjects_h*/
| [
"aidanontour@yahoo.co.uk"
] | aidanontour@yahoo.co.uk |
83ce75ae4fd3e693e38cbfb6a4f04bc116115925 | 9eea4309495a9391d2d48cbd57f706408a5f44d7 | /0x06-pointers_arrays_strings/8-rot13.c | ab861dcf558a1d8b410ee2d3fdae5a1ab7678ba5 | [] | no_license | melisarv/holbertonschool-low_level_programming | 1468598d2d0effd5bfb6f8161434875dea33a635 | 15ed5a4e5728aeb7d833d79697f9d7d85a72f5d9 | refs/heads/main | 2023-07-17T10:23:35.076729 | 2021-09-05T03:45:03 | 2021-09-05T03:45:03 | 335,794,419 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 490 | c | #include "holberton.h"
/**
* rot13 - function that encodes a string using rot13
* @s: point to be encode
* Return: point result
*/
char *rot13(char *s)
{
int i = 0, j, len;
char in[52] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char out[52] = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";
len = 52;
while (s[i] != '\0')
{
j = 0;
while (j < len)
{
if (s[i] == in[j])
{
s[i] = out[j];
break;
}
j++;
}
i++;
}
return (s);
}
| [
"melisarv@gmail.com"
] | melisarv@gmail.com |
7ca68a52c9439fe2fdc079ba9fe3eee243318415 | 70835d20cdf1f3ad40341181f0f411f76dbb6e9d | /preload-mimalloc/mimalloc/src/prim/unix/prim.c | 011ffa7cdb80b7f042719e395935f6c97cf81d9e | [
"LicenseRef-scancode-generic-cla",
"MIT",
"Apache-2.0"
] | permissive | hasura/graphql-engine | b47ef40cfa9a043317af3ac01f7b5b41fd9d4042 | 0920a78e5a4970143bc6f00836cd98eee0ea9759 | refs/heads/master | 2023-09-04T13:08:47.643089 | 2023-09-04T08:28:39 | 2023-09-04T08:30:26 | 137,724,480 | 31,840 | 3,367 | Apache-2.0 | 2023-09-13T11:40:05 | 2018-06-18T07:57:36 | TypeScript | UTF-8 | C | false | false | 27,411 | c | /* ----------------------------------------------------------------------------
Copyright (c) 2018-2023, Microsoft Research, Daan Leijen
This is free software; you can redistribute it and/or modify it under the
terms of the MIT license. A copy of the license can be found in the file
"LICENSE" at the root of this distribution.
-----------------------------------------------------------------------------*/
// This file is included in `src/prim/prim.c`
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE // ensure mmap flags and syscall are defined
#endif
#if defined(__sun)
// illumos provides new mman.h api when any of these are defined
// otherwise the old api based on caddr_t which predates the void pointers one.
// stock solaris provides only the former, chose to atomically to discard those
// flags only here rather than project wide tough.
#undef _XOPEN_SOURCE
#undef _POSIX_C_SOURCE
#endif
#include "mimalloc.h"
#include "mimalloc/internal.h"
#include "mimalloc/atomic.h"
#include "mimalloc/prim.h"
#include <sys/mman.h> // mmap
#include <unistd.h> // sysconf
#if defined(__linux__)
#include <features.h>
#include <fcntl.h>
#if defined(__GLIBC__)
#include <linux/mman.h> // linux mmap flags
#else
#include <sys/mman.h>
#endif
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#if !TARGET_IOS_IPHONE && !TARGET_IOS_SIMULATOR
#include <mach/vm_statistics.h>
#endif
#elif defined(__FreeBSD__) || defined(__DragonFly__)
#include <sys/param.h>
#if __FreeBSD_version >= 1200000
#include <sys/cpuset.h>
#include <sys/domainset.h>
#endif
#include <sys/sysctl.h>
#endif
#if !defined(__HAIKU__) && !defined(__APPLE__) && !defined(__CYGWIN__)
#define MI_HAS_SYSCALL_H
#include <sys/syscall.h>
#endif
//------------------------------------------------------------------------------------
// Use syscalls for some primitives to allow for libraries that override open/read/close etc.
// and do allocation themselves; using syscalls prevents recursion when mimalloc is
// still initializing (issue #713)
//------------------------------------------------------------------------------------
#if defined(MI_HAS_SYSCALL_H) && defined(SYS_open) && defined(SYS_close) && defined(SYS_read) && defined(SYS_access)
static int mi_prim_open(const char* fpath, int open_flags) {
return syscall(SYS_open,fpath,open_flags,0);
}
static ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) {
return syscall(SYS_read,fd,buf,bufsize);
}
static int mi_prim_close(int fd) {
return syscall(SYS_close,fd);
}
static int mi_prim_access(const char *fpath, int mode) {
return syscall(SYS_access,fpath,mode);
}
#elif !defined(__APPLE__) // avoid unused warnings
static int mi_prim_open(const char* fpath, int open_flags) {
return open(fpath,open_flags);
}
static ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) {
return read(fd,buf,bufsize);
}
static int mi_prim_close(int fd) {
return close(fd);
}
static int mi_prim_access(const char *fpath, int mode) {
return access(fpath,mode);
}
#endif
//---------------------------------------------
// init
//---------------------------------------------
static bool unix_detect_overcommit(void) {
bool os_overcommit = true;
#if defined(__linux__)
int fd = mi_prim_open("/proc/sys/vm/overcommit_memory", O_RDONLY);
if (fd >= 0) {
char buf[32];
ssize_t nread = mi_prim_read(fd, &buf, sizeof(buf));
mi_prim_close(fd);
// <https://www.kernel.org/doc/Documentation/vm/overcommit-accounting>
// 0: heuristic overcommit, 1: always overcommit, 2: never overcommit (ignore NORESERVE)
if (nread >= 1) {
os_overcommit = (buf[0] == '0' || buf[0] == '1');
}
}
#elif defined(__FreeBSD__)
int val = 0;
size_t olen = sizeof(val);
if (sysctlbyname("vm.overcommit", &val, &olen, NULL, 0) == 0) {
os_overcommit = (val != 0);
}
#else
// default: overcommit is true
#endif
return os_overcommit;
}
void _mi_prim_mem_init( mi_os_mem_config_t* config ) {
long psize = sysconf(_SC_PAGESIZE);
if (psize > 0) {
config->page_size = (size_t)psize;
config->alloc_granularity = (size_t)psize;
}
config->large_page_size = 2*MI_MiB; // TODO: can we query the OS for this?
config->has_overcommit = unix_detect_overcommit();
config->must_free_whole = false; // mmap can free in parts
}
//---------------------------------------------
// free
//---------------------------------------------
int _mi_prim_free(void* addr, size_t size ) {
bool err = (munmap(addr, size) == -1);
return (err ? errno : 0);
}
//---------------------------------------------
// mmap
//---------------------------------------------
static int unix_madvise(void* addr, size_t size, int advice) {
#if defined(__sun)
return madvise((caddr_t)addr, size, advice); // Solaris needs cast (issue #520)
#else
return madvise(addr, size, advice);
#endif
}
static void* unix_mmap_prim(void* addr, size_t size, size_t try_alignment, int protect_flags, int flags, int fd) {
MI_UNUSED(try_alignment);
void* p = NULL;
#if defined(MAP_ALIGNED) // BSD
if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0) {
size_t n = mi_bsr(try_alignment);
if (((size_t)1 << n) == try_alignment && n >= 12 && n <= 30) { // alignment is a power of 2 and 4096 <= alignment <= 1GiB
p = mmap(addr, size, protect_flags, flags | MAP_ALIGNED(n), fd, 0);
if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) {
int err = errno;
_mi_warning_message("unable to directly request aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx, hint address: %p)\n", err, err, size, try_alignment, hint);
}
if (p!=MAP_FAILED) return p;
// fall back to regular mmap
}
}
#elif defined(MAP_ALIGN) // Solaris
if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0) {
p = mmap((void*)try_alignment, size, protect_flags, flags | MAP_ALIGN, fd, 0); // addr parameter is the required alignment
if (p!=MAP_FAILED) return p;
// fall back to regular mmap
}
#endif
#if (MI_INTPTR_SIZE >= 8) && !defined(MAP_ALIGNED)
// on 64-bit systems, use the virtual address area after 2TiB for 4MiB aligned allocations
if (addr == NULL) {
void* hint = _mi_os_get_aligned_hint(try_alignment, size);
if (hint != NULL) {
p = mmap(hint, size, protect_flags, flags, fd, 0);
if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) {
int err = errno;
_mi_warning_message("unable to directly request hinted aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx, hint address: %p)\n", err, err, size, try_alignment, hint);
}
if (p!=MAP_FAILED) return p;
// fall back to regular mmap
}
}
#endif
// regular mmap
p = mmap(addr, size, protect_flags, flags, fd, 0);
if (p!=MAP_FAILED) return p;
// failed to allocate
return NULL;
}
static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protect_flags, bool large_only, bool allow_large, bool* is_large) {
void* p = NULL;
#if !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
#if !defined(MAP_NORESERVE)
#define MAP_NORESERVE 0
#endif
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
int fd = -1;
if (_mi_os_has_overcommit()) {
flags |= MAP_NORESERVE;
}
#if defined(PROT_MAX)
protect_flags |= PROT_MAX(PROT_READ | PROT_WRITE); // BSD
#endif
#if defined(VM_MAKE_TAG)
// macOS: tracking anonymous page with a specific ID. (All up to 98 are taken officially but LLVM sanitizers had taken 99)
int os_tag = (int)mi_option_get(mi_option_os_tag);
if (os_tag < 100 || os_tag > 255) { os_tag = 100; }
fd = VM_MAKE_TAG(os_tag);
#endif
// huge page allocation
if ((large_only || _mi_os_use_large_page(size, try_alignment)) && allow_large) {
static _Atomic(size_t) large_page_try_ok; // = 0;
size_t try_ok = mi_atomic_load_acquire(&large_page_try_ok);
if (!large_only && try_ok > 0) {
// If the OS is not configured for large OS pages, or the user does not have
// enough permission, the `mmap` will always fail (but it might also fail for other reasons).
// Therefore, once a large page allocation failed, we don't try again for `large_page_try_ok` times
// to avoid too many failing calls to mmap.
mi_atomic_cas_strong_acq_rel(&large_page_try_ok, &try_ok, try_ok - 1);
}
else {
int lflags = flags & ~MAP_NORESERVE; // using NORESERVE on huge pages seems to fail on Linux
int lfd = fd;
#ifdef MAP_ALIGNED_SUPER
lflags |= MAP_ALIGNED_SUPER;
#endif
#ifdef MAP_HUGETLB
lflags |= MAP_HUGETLB;
#endif
#ifdef MAP_HUGE_1GB
static bool mi_huge_pages_available = true;
if ((size % MI_GiB) == 0 && mi_huge_pages_available) {
lflags |= MAP_HUGE_1GB;
}
else
#endif
{
#ifdef MAP_HUGE_2MB
lflags |= MAP_HUGE_2MB;
#endif
}
#ifdef VM_FLAGS_SUPERPAGE_SIZE_2MB
lfd |= VM_FLAGS_SUPERPAGE_SIZE_2MB;
#endif
if (large_only || lflags != flags) {
// try large OS page allocation
*is_large = true;
p = unix_mmap_prim(addr, size, try_alignment, protect_flags, lflags, lfd);
#ifdef MAP_HUGE_1GB
if (p == NULL && (lflags & MAP_HUGE_1GB) != 0) {
mi_huge_pages_available = false; // don't try huge 1GiB pages again
_mi_warning_message("unable to allocate huge (1GiB) page, trying large (2MiB) pages instead (errno: %i)\n", errno);
lflags = ((lflags & ~MAP_HUGE_1GB) | MAP_HUGE_2MB);
p = unix_mmap_prim(addr, size, try_alignment, protect_flags, lflags, lfd);
}
#endif
if (large_only) return p;
if (p == NULL) {
mi_atomic_store_release(&large_page_try_ok, (size_t)8); // on error, don't try again for the next N allocations
}
}
}
}
// regular allocation
if (p == NULL) {
*is_large = false;
p = unix_mmap_prim(addr, size, try_alignment, protect_flags, flags, fd);
if (p != NULL) {
#if defined(MADV_HUGEPAGE)
// Many Linux systems don't allow MAP_HUGETLB but they support instead
// transparent huge pages (THP). Generally, it is not required to call `madvise` with MADV_HUGE
// though since properly aligned allocations will already use large pages if available
// in that case -- in particular for our large regions (in `memory.c`).
// However, some systems only allow THP if called with explicit `madvise`, so
// when large OS pages are enabled for mimalloc, we call `madvise` anyways.
if (allow_large && _mi_os_use_large_page(size, try_alignment)) {
if (unix_madvise(p, size, MADV_HUGEPAGE) == 0) {
*is_large = true; // possibly
};
}
#elif defined(__sun)
if (allow_large && _mi_os_use_large_page(size, try_alignment)) {
struct memcntl_mha cmd = {0};
cmd.mha_pagesize = large_os_page_size;
cmd.mha_cmd = MHA_MAPSIZE_VA;
if (memcntl((caddr_t)p, size, MC_HAT_ADVISE, (caddr_t)&cmd, 0, 0) == 0) {
*is_large = true;
}
}
#endif
}
}
return p;
}
// Note: the `try_alignment` is just a hint and the returned pointer is not guaranteed to be aligned.
int _mi_prim_alloc(size_t size, size_t try_alignment, bool commit, bool allow_large, bool* is_large, void** addr) {
mi_assert_internal(size > 0 && (size % _mi_os_page_size()) == 0);
mi_assert_internal(commit || !allow_large);
mi_assert_internal(try_alignment > 0);
int protect_flags = (commit ? (PROT_WRITE | PROT_READ) : PROT_NONE);
*addr = unix_mmap(NULL, size, try_alignment, protect_flags, false, allow_large, is_large);
return (*addr != NULL ? 0 : errno);
}
//---------------------------------------------
// Commit/Reset
//---------------------------------------------
static void unix_mprotect_hint(int err) {
#if defined(__linux__) && (MI_SECURE>=2) // guard page around every mimalloc page
if (err == ENOMEM) {
_mi_warning_message("The next warning may be caused by a low memory map limit.\n"
" On Linux this is controlled by the vm.max_map_count -- maybe increase it?\n"
" For example: sudo sysctl -w vm.max_map_count=262144\n");
}
#else
MI_UNUSED(err);
#endif
}
int _mi_prim_commit(void* start, size_t size, bool commit) {
/*
#if 0 && defined(MAP_FIXED) && !defined(__APPLE__)
// Linux: disabled for now as mmap fixed seems much more expensive than MADV_DONTNEED (and splits VMA's?)
if (commit) {
// commit: just change the protection
err = mprotect(start, csize, (PROT_READ | PROT_WRITE));
if (err != 0) { err = errno; }
}
else {
// decommit: use mmap with MAP_FIXED to discard the existing memory (and reduce rss)
const int fd = mi_unix_mmap_fd();
void* p = mmap(start, csize, PROT_NONE, (MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE), fd, 0);
if (p != start) { err = errno; }
}
#else
*/
int err = 0;
if (commit) {
// commit: ensure we can access the area
err = mprotect(start, size, (PROT_READ | PROT_WRITE));
if (err != 0) { err = errno; }
}
else {
#if defined(MADV_DONTNEED) && MI_DEBUG == 0 && MI_SECURE == 0
// decommit: use MADV_DONTNEED as it decreases rss immediately (unlike MADV_FREE)
// (on the other hand, MADV_FREE would be good enough.. it is just not reflected in the stats :-( )
err = unix_madvise(start, size, MADV_DONTNEED);
#else
// decommit: just disable access (also used in debug and secure mode to trap on illegal access)
err = mprotect(start, size, PROT_NONE);
if (err != 0) { err = errno; }
#endif
}
unix_mprotect_hint(err);
return err;
}
int _mi_prim_reset(void* start, size_t size) {
#if defined(MADV_FREE)
static _Atomic(size_t) advice = MI_ATOMIC_VAR_INIT(MADV_FREE);
int oadvice = (int)mi_atomic_load_relaxed(&advice);
int err;
while ((err = unix_madvise(start, size, oadvice)) != 0 && errno == EAGAIN) { errno = 0; };
if (err != 0 && errno == EINVAL && oadvice == MADV_FREE) {
// if MADV_FREE is not supported, fall back to MADV_DONTNEED from now on
mi_atomic_store_release(&advice, (size_t)MADV_DONTNEED);
err = unix_madvise(start, size, MADV_DONTNEED);
}
#else
int err = unix_madvise(start, size, MADV_DONTNEED);
#endif
return err;
}
int _mi_prim_protect(void* start, size_t size, bool protect) {
int err = mprotect(start, size, protect ? PROT_NONE : (PROT_READ | PROT_WRITE));
if (err != 0) { err = errno; }
unix_mprotect_hint(err);
return err;
}
//---------------------------------------------
// Huge page allocation
//---------------------------------------------
#if (MI_INTPTR_SIZE >= 8) && !defined(__HAIKU__) && !defined(__CYGWIN__)
#ifndef MPOL_PREFERRED
#define MPOL_PREFERRED 1
#endif
#if defined(MI_HAS_SYSCALL_H) && defined(SYS_mbind)
static long mi_prim_mbind(void* start, unsigned long len, unsigned long mode, const unsigned long* nmask, unsigned long maxnode, unsigned flags) {
return syscall(SYS_mbind, start, len, mode, nmask, maxnode, flags);
}
#else
static long mi_prim_mbind(void* start, unsigned long len, unsigned long mode, const unsigned long* nmask, unsigned long maxnode, unsigned flags) {
MI_UNUSED(start); MI_UNUSED(len); MI_UNUSED(mode); MI_UNUSED(nmask); MI_UNUSED(maxnode); MI_UNUSED(flags);
return 0;
}
#endif
int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, void** addr) {
bool is_large = true;
*addr = unix_mmap(hint_addr, size, MI_SEGMENT_SIZE, PROT_READ | PROT_WRITE, true, true, &is_large);
if (*addr != NULL && numa_node >= 0 && numa_node < 8*MI_INTPTR_SIZE) { // at most 64 nodes
unsigned long numa_mask = (1UL << numa_node);
// TODO: does `mbind` work correctly for huge OS pages? should we
// use `set_mempolicy` before calling mmap instead?
// see: <https://lkml.org/lkml/2017/2/9/875>
long err = mi_prim_mbind(*addr, size, MPOL_PREFERRED, &numa_mask, 8*MI_INTPTR_SIZE, 0);
if (err != 0) {
err = errno;
_mi_warning_message("failed to bind huge (1GiB) pages to numa node %d (error: %d (0x%x))\n", numa_node, err, err);
}
}
return (*addr != NULL ? 0 : errno);
}
#else
int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, void** addr) {
MI_UNUSED(hint_addr); MI_UNUSED(size); MI_UNUSED(numa_node);
*addr = NULL;
return ENOMEM;
}
#endif
//---------------------------------------------
// NUMA nodes
//---------------------------------------------
#if defined(__linux__)
#include <stdio.h> // snprintf
size_t _mi_prim_numa_node(void) {
#if defined(MI_HAS_SYSCALL_H) && defined(SYS_getcpu)
unsigned long node = 0;
unsigned long ncpu = 0;
long err = syscall(SYS_getcpu, &ncpu, &node, NULL);
if (err != 0) return 0;
return node;
#else
return 0;
#endif
}
size_t _mi_prim_numa_node_count(void) {
char buf[128];
unsigned node = 0;
for(node = 0; node < 256; node++) {
// enumerate node entries -- todo: it there a more efficient way to do this? (but ensure there is no allocation)
snprintf(buf, 127, "/sys/devices/system/node/node%u", node + 1);
if (mi_prim_access(buf,R_OK) != 0) break;
}
return (node+1);
}
#elif defined(__FreeBSD__) && __FreeBSD_version >= 1200000
size_t _mi_prim_numa_node(void) {
domainset_t dom;
size_t node;
int policy;
if (cpuset_getdomain(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, sizeof(dom), &dom, &policy) == -1) return 0ul;
for (node = 0; node < MAXMEMDOM; node++) {
if (DOMAINSET_ISSET(node, &dom)) return node;
}
return 0ul;
}
size_t _mi_prim_numa_node_count(void) {
size_t ndomains = 0;
size_t len = sizeof(ndomains);
if (sysctlbyname("vm.ndomains", &ndomains, &len, NULL, 0) == -1) return 0ul;
return ndomains;
}
#elif defined(__DragonFly__)
size_t _mi_prim_numa_node(void) {
// TODO: DragonFly does not seem to provide any userland means to get this information.
return 0ul;
}
size_t _mi_prim_numa_node_count(void) {
size_t ncpus = 0, nvirtcoresperphys = 0;
size_t len = sizeof(size_t);
if (sysctlbyname("hw.ncpu", &ncpus, &len, NULL, 0) == -1) return 0ul;
if (sysctlbyname("hw.cpu_topology_ht_ids", &nvirtcoresperphys, &len, NULL, 0) == -1) return 0ul;
return nvirtcoresperphys * ncpus;
}
#else
size_t _mi_prim_numa_node(void) {
return 0;
}
size_t _mi_prim_numa_node_count(void) {
return 1;
}
#endif
// ----------------------------------------------------------------
// Clock
// ----------------------------------------------------------------
#include <time.h>
#if defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC)
mi_msecs_t _mi_prim_clock_now(void) {
struct timespec t;
#ifdef CLOCK_MONOTONIC
clock_gettime(CLOCK_MONOTONIC, &t);
#else
clock_gettime(CLOCK_REALTIME, &t);
#endif
return ((mi_msecs_t)t.tv_sec * 1000) + ((mi_msecs_t)t.tv_nsec / 1000000);
}
#else
// low resolution timer
mi_msecs_t _mi_prim_clock_now(void) {
#if !defined(CLOCKS_PER_SEC) || (CLOCKS_PER_SEC == 1000) || (CLOCKS_PER_SEC == 0)
return (mi_msecs_t)clock();
#elif (CLOCKS_PER_SEC < 1000)
return (mi_msecs_t)clock() * (1000 / (mi_msecs_t)CLOCKS_PER_SEC);
#else
return (mi_msecs_t)clock() / ((mi_msecs_t)CLOCKS_PER_SEC / 1000);
#endif
}
#endif
//----------------------------------------------------------------
// Process info
//----------------------------------------------------------------
#if defined(__unix__) || defined(__unix) || defined(unix) || defined(__APPLE__) || defined(__HAIKU__)
#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
#if defined(__APPLE__)
#include <mach/mach.h>
#endif
#if defined(__HAIKU__)
#include <kernel/OS.h>
#endif
static mi_msecs_t timeval_secs(const struct timeval* tv) {
return ((mi_msecs_t)tv->tv_sec * 1000L) + ((mi_msecs_t)tv->tv_usec / 1000L);
}
void _mi_prim_process_info(mi_process_info_t* pinfo)
{
struct rusage rusage;
getrusage(RUSAGE_SELF, &rusage);
pinfo->utime = timeval_secs(&rusage.ru_utime);
pinfo->stime = timeval_secs(&rusage.ru_stime);
#if !defined(__HAIKU__)
pinfo->page_faults = rusage.ru_majflt;
#endif
#if defined(__HAIKU__)
// Haiku does not have (yet?) a way to
// get these stats per process
thread_info tid;
area_info mem;
ssize_t c;
get_thread_info(find_thread(0), &tid);
while (get_next_area_info(tid.team, &c, &mem) == B_OK) {
pinfo->peak_rss += mem.ram_size;
}
pinfo->page_faults = 0;
#elif defined(__APPLE__)
pinfo->peak_rss = rusage.ru_maxrss; // macos reports in bytes
struct mach_task_basic_info info;
mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&info, &infoCount) == KERN_SUCCESS) {
pinfo->current_rss = (size_t)info.resident_size;
}
#else
pinfo->peak_rss = rusage.ru_maxrss * 1024; // Linux/BSD report in KiB
#endif
// use defaults for commit
}
#else
#ifndef __wasi__
// WebAssembly instances are not processes
#pragma message("define a way to get process info")
#endif
void _mi_prim_process_info(mi_process_info_t* pinfo)
{
// use defaults
MI_UNUSED(pinfo);
}
#endif
//----------------------------------------------------------------
// Output
//----------------------------------------------------------------
void _mi_prim_out_stderr( const char* msg ) {
fputs(msg,stderr);
}
//----------------------------------------------------------------
// Environment
//----------------------------------------------------------------
#if !defined(MI_USE_ENVIRON) || (MI_USE_ENVIRON!=0)
// On Posix systemsr use `environ` to access environment variables
// even before the C runtime is initialized.
#if defined(__APPLE__) && defined(__has_include) && __has_include(<crt_externs.h>)
#include <crt_externs.h>
static char** mi_get_environ(void) {
return (*_NSGetEnviron());
}
#else
extern char** environ;
static char** mi_get_environ(void) {
return environ;
}
#endif
bool _mi_prim_getenv(const char* name, char* result, size_t result_size) {
if (name==NULL) return false;
const size_t len = _mi_strlen(name);
if (len == 0) return false;
char** env = mi_get_environ();
if (env == NULL) return false;
// compare up to 10000 entries
for (int i = 0; i < 10000 && env[i] != NULL; i++) {
const char* s = env[i];
if (_mi_strnicmp(name, s, len) == 0 && s[len] == '=') { // case insensitive
// found it
_mi_strlcpy(result, s + len + 1, result_size);
return true;
}
}
return false;
}
#else
// fallback: use standard C `getenv` but this cannot be used while initializing the C runtime
bool _mi_prim_getenv(const char* name, char* result, size_t result_size) {
// cannot call getenv() when still initializing the C runtime.
if (_mi_preloading()) return false;
const char* s = getenv(name);
if (s == NULL) {
// we check the upper case name too.
char buf[64+1];
size_t len = _mi_strnlen(name,sizeof(buf)-1);
for (size_t i = 0; i < len; i++) {
buf[i] = _mi_toupper(name[i]);
}
buf[len] = 0;
s = getenv(buf);
}
if (s == NULL || _mi_strnlen(s,result_size) >= result_size) return false;
_mi_strlcpy(result, s, result_size);
return true;
}
#endif // !MI_USE_ENVIRON
//----------------------------------------------------------------
// Random
//----------------------------------------------------------------
#if defined(__APPLE__)
#include <AvailabilityMacros.h>
#if defined(MAC_OS_X_VERSION_10_10) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
#include <CommonCrypto/CommonCryptoError.h>
#include <CommonCrypto/CommonRandom.h>
#endif
bool _mi_prim_random_buf(void* buf, size_t buf_len) {
#if defined(MAC_OS_X_VERSION_10_15) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15
// We prefere CCRandomGenerateBytes as it returns an error code while arc4random_buf
// may fail silently on macOS. See PR #390, and <https://opensource.apple.com/source/Libc/Libc-1439.40.11/gen/FreeBSD/arc4random.c.auto.html>
return (CCRandomGenerateBytes(buf, buf_len) == kCCSuccess);
#else
// fall back on older macOS
arc4random_buf(buf, buf_len);
return true;
#endif
}
#elif defined(__ANDROID__) || defined(__DragonFly__) || \
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__sun)
#include <stdlib.h>
bool _mi_prim_random_buf(void* buf, size_t buf_len) {
arc4random_buf(buf, buf_len);
return true;
}
#elif defined(__linux__) || defined(__HAIKU__)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
bool _mi_prim_random_buf(void* buf, size_t buf_len) {
// Modern Linux provides `getrandom` but different distributions either use `sys/random.h` or `linux/random.h`
// and for the latter the actual `getrandom` call is not always defined.
// (see <https://stackoverflow.com/questions/45237324/why-doesnt-getrandom-compile>)
// We therefore use a syscall directly and fall back dynamically to /dev/urandom when needed.
#if defined(MI_HAS_SYSCALL_H) && defined(SYS_getrandom)
#ifndef GRND_NONBLOCK
#define GRND_NONBLOCK (1)
#endif
static _Atomic(uintptr_t) no_getrandom; // = 0
if (mi_atomic_load_acquire(&no_getrandom)==0) {
ssize_t ret = syscall(SYS_getrandom, buf, buf_len, GRND_NONBLOCK);
if (ret >= 0) return (buf_len == (size_t)ret);
if (errno != ENOSYS) return false;
mi_atomic_store_release(&no_getrandom, (uintptr_t)1); // don't call again, and fall back to /dev/urandom
}
#endif
int flags = O_RDONLY;
#if defined(O_CLOEXEC)
flags |= O_CLOEXEC;
#endif
int fd = mi_prim_open("/dev/urandom", flags);
if (fd < 0) return false;
size_t count = 0;
while(count < buf_len) {
ssize_t ret = mi_prim_read(fd, (char*)buf + count, buf_len - count);
if (ret<=0) {
if (errno!=EAGAIN && errno!=EINTR) break;
}
else {
count += ret;
}
}
mi_prim_close(fd);
return (count==buf_len);
}
#else
bool _mi_prim_random_buf(void* buf, size_t buf_len) {
return false;
}
#endif
//----------------------------------------------------------------
// Thread init/done
//----------------------------------------------------------------
#if defined(MI_USE_PTHREADS)
// use pthread local storage keys to detect thread ending
// (and used with MI_TLS_PTHREADS for the default heap)
pthread_key_t _mi_heap_default_key = (pthread_key_t)(-1);
static void mi_pthread_done(void* value) {
if (value!=NULL) {
_mi_thread_done((mi_heap_t*)value);
}
}
void _mi_prim_thread_init_auto_done(void) {
mi_assert_internal(_mi_heap_default_key == (pthread_key_t)(-1));
pthread_key_create(&_mi_heap_default_key, &mi_pthread_done);
}
void _mi_prim_thread_done_auto_done(void) {
// nothing to do
}
void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) {
if (_mi_heap_default_key != (pthread_key_t)(-1)) { // can happen during recursive invocation on freeBSD
pthread_setspecific(_mi_heap_default_key, heap);
}
}
#else
void _mi_prim_thread_init_auto_done(void) {
// nothing
}
void _mi_prim_thread_done_auto_done(void) {
// nothing
}
void _mi_prim_thread_associate_default_heap(mi_heap_t* heap) {
MI_UNUSED(heap);
}
#endif
| [
"accounts@hasura.io"
] | accounts@hasura.io |
c51b25a4f61eac2f3a55a4018ee9381c5e2c781b | 6c9935a31d3f09325c1fe64bc7da7a31c4c919d2 | /c_programming/ScanFDemo2.c | e64fed06006afe361a67dcc976b41479c1f90eaf | [] | no_license | nikcur/misa_lihvarcek | b3609c8fd68607eda3d2cc04ec729c125b6f94aa | 9b8fb1a29e1abc7aad43c67f9271181240584e6b | refs/heads/master | 2021-03-25T08:55:50.132885 | 2019-08-09T09:44:48 | 2019-08-09T09:44:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 204 | c | #include <stdio.h>
int main(){
char food[5];
printf("Enter favourite food: ");
scanf("%s", food); //if input is too long program crashes
printf("Favourite food: %s\n", food);
return 0;
}
| [
"lihvarcekmisa@yahoo.com"
] | lihvarcekmisa@yahoo.com |
873aa938e58b152a4366c39c4c762ce45f992625 | d97d6b1f69b56d009f290cf515dfa77669277109 | /slist.c | 26faa977ebc926e13d04811afaaea42306014192 | [] | no_license | Alfredo9437/223-AlfredoRodriguez | bd6ee1688209c7bcd6db3fc331211e0b5cc05de3 | 126e74873405973a03f0d4a7787f968fd3b69b4c | refs/heads/master | 2022-04-16T04:37:32.007145 | 2020-04-11T18:02:19 | 2020-04-11T18:02:19 | 254,925,472 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,806 | c | #include "slist.h"
#include <stdlib.h>
snode* snode_create(int data, snode* next){
snode*temp = (snode*)malloc(sizeof(snode));
temp->data = data;
temp->next = next;
return temp;
}
slist* slist_create(void){
slist*temp = (slist*)malloc(sizeof(slist));
temp->head = NULL;
temp->tail = NULL;
temp->size = 0;
return temp;
}
bool slist_empty(slist* list){ return (list->size == 0); }
size_t slist_size(slist* list){ return list->size; }
void slist_popfront(slist* list){
if(list->size == 0){ printf("list is empty..."); return;}
snode*oldhead = list->head;
list->head = list->head->next;
free(oldhead);
--list->size;
}
void slist_popback(slist* list){
if(list->size == 0){ printf("list is empty..."); return;}
snode*newtail = list->head;
while(newtail->next != list->tail){newtail = newtail->next;}
newtail->next = NULL;
free(list->tail);
list->tail = newtail;
--list->size;
}
void slist_pushfront(slist* list, int data){
snode*newhead = snode_create(data, list->head);
list->head = newhead;
if(list->size == 0){ list->tail = newhead; }
++list->size;
}
void slist_pushback(slist* list, int data){
snode*newtail = snode_create(data, NULL);
list->tail->next = newtail;
list->tail = newtail;
if(list->size == 0){list->head = newtail;}
++list->size;
}
void slist_clear(slist* list){
while(list->size != 0){
slist_popfront(list);
}
}
void slist_print(slist* list, const char* msg){
snode*reader=list->head;
printf("%s\n", msg);
while(reader != NULL){
printf("%d --> %p\n", reader->data, reader->next);
reader = reader->next;
}
}
int slist_front(slist* list){ return list->head->data; }
int slist_back(slist* list){ return list->tail->data; } | [
"noreply@github.com"
] | Alfredo9437.noreply@github.com |
2165a632ffb4d0abc68f26b7ebefbfe36a8ec105 | 1adb643675f0b144641d608d8f21d5a288c520e3 | /swz.C | 4e06e4193c47d7691a3c56ebedd7b1ca07190275 | [] | no_license | jianglin332/codes | 5c965fdfca589fbbca5b651b92e4fdf64b09fd7a | a8a095d6da3df14b1d4fd0b12f7b58e9b366ed78 | refs/heads/master | 2021-05-04T12:57:19.770343 | 2018-02-05T12:50:53 | 2018-02-05T12:50:53 | 120,303,772 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 532 | c | #include <cstdio>
int main()
{
int m, s, _t;
scanf("%d%d%d", &m, &s, &_t);
int t = _t;
int n = s;
while (t)
{
if (m >= 10)
{
t -= 1;
m -= 10;
n -= 60;
}
else if (m >= 6 && t >= 2 && n > 17)
{
t -= 2;
m -= 6;
n -= 60;
}
else if (m >= 2 && t >= 3 && n > 34)
{
t -= 3;
m -= 2;
n -= 60;
}
else if (t >= 7 && n > 102)
{
t -= 7;
n -= 120;
}
else
{
t -= 1;
n -= 17;
}
if (n <= 0)
{
printf("Yes\n%d", _t - t);
return 0;
}
}
printf("No\n%d", s - n);
}
| [
"jianglin332@outlook.com"
] | jianglin332@outlook.com |
737f6b2c6f0a07db2875cf77c2dac6cfbb2c2521 | dae827116f570fcc166d2eb7c35ce3e045f32a8e | /extensions/cce/src/main/jni/lib_ccx/ccx_encoders_splitbysentence.c | 0707f842d197040a44b79626e78809d5817c9f7f | [
"Apache-2.0"
] | permissive | wazerstar/Exo-CC | 6d9a5db4148f1195e67d2e89c8a618eed17261be | aa508582d4e6b1ea08eb1a281296fb21d13d05cb | refs/heads/main | 2023-02-16T03:21:41.793620 | 2021-01-12T00:52:18 | 2021-01-12T00:52:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 16,954 | c | /**
*
* This is an implementation of Sentence Break Buffer
* It is still in development and could contain bugs
* If you will find bugs in SBS, you could try to create an
* issue in the forked repository:
*
* https://github.com/maxkoryukov/ccextractor/issues
* Only SBS-related bugs!
*
* IMPORTANT: SBS is color-blind, and color tags mislead SBS.
* Please, use `-sbs` option with `-nofc` (actual for CCE 0.8.5)
*/
#include "ccx_common_platform.h"
#include "ccx_encoders_common.h"
#include "lib_ccx.h"
#include "ocr.h"
#include "utility.h"
// #define DEBUG_SBS
// #define ENABLE_OCR
#ifdef DEBUG_SBS
#define LOG_DEBUG(...) fprintf(stdout, __VA_ARGS__)
#else
#define LOG_DEBUG(...)
#endif
#ifdef ENABLE_SHARING
#include "ccx_share.h"
#endif //ENABLE_SHARING
//---------------------------
// BEGIN of #BUG639
// HACK: this is workaround for https://github.com/CCExtractor/ccextractor/issues/639
// short: the outside function, called encode_sub changes ENCODER_CONTEXT when it required..
// as result SBS loses it internal state...
// #BUG639
typedef struct
{
unsigned char *buffer; /// Storage for sentence-split buffer
size_t handled_len; /// The length of the string in the SBS-buffer, already handled, but preserved for DUP-detection.
//ccx_sbs_utf8_character *sbs_newblock;
LLONG time_from; // Used by the split-by-sentence code to know when the current block starts...
LLONG time_trim; // ... and ends
size_t capacity;
} sbs_context_t;
// DO NOT USE IT DIRECTLY!
// The only one exceptions:
// 1. init_sbs_context
sbs_context_t *____sbs_context = NULL;
/**
* Initializes SBS settings for encoder context
*/
void sbs_reset_context()
{
if (NULL != ____sbs_context)
{
free(____sbs_context);
____sbs_context = NULL;
}
}
//void init_encoder_sbs(struct encoder_ctx * ctx, const int splitbysentence);
sbs_context_t *sbs_init_context()
{
LOG_DEBUG("SBS: init_sbs_context\n\
____sbs_context: [%p]\n\
",
____sbs_context);
if (NULL == ____sbs_context)
{
LOG_DEBUG("SBS: init_sbs_context: INIT\n");
____sbs_context = malloc(sizeof(sbs_context_t));
____sbs_context->time_from = -1;
____sbs_context->time_trim = -1;
____sbs_context->capacity = 16;
____sbs_context->buffer = malloc(____sbs_context->capacity * sizeof(unsigned char));
____sbs_context->buffer[0] = 0;
____sbs_context->handled_len = 0;
}
LOG_DEBUG("SBS: init_sbs_context: DONE\n\
____sbs_context: [%p]\n\
",
____sbs_context);
return ____sbs_context;
}
// END of #BUG639
//---------------------------
void sbs_str_autofix(unsigned char *str)
{
LOG_DEBUG("SBS: sbs_str_autofix\n\
\t old str: [%s]\n\
",
str);
int i;
int j;
i = 0;
j = 0;
// replace all whitespaces with spaces:
while (str[i] != 0)
{
if (isspace(str[i]))
{
// \n
// \t
// \r
// <WHITESPACES>
// =>
// <SPACE>
while (isspace(str[i]))
{
i++;
}
if (j > 0)
{
str[j] = ' ';
j++;
}
}
else if (
str[i] == '|' && (i == 0 || isspace(str[i - 1])) && (str[i + 1] == 0 || isspace(str[i + 1]) || str[i + 1] == '\''))
{
// <SPACE>|'
// <SPACE>|<SPACE>
// =>
// <SPACE>I'
str[j] = 'I';
i++;
j++;
}
else
{
str[j] = str[i];
i++;
j++;
}
}
str[j] = 0;
LOG_DEBUG("SBS: sbs_str_autofix\n\
\t old str: [%s]\n\
",
str);
}
int sbs_is_pointer_on_sentence_breaker(char *start, char *current)
{
char c = *current;
char n = *(current + 1);
if (0 == c)
return 1;
if ('.' == c || '!' == c || '?' == c)
{
if ('.' == n || '!' == n || '?' == n)
{
return 0;
}
return 1;
}
return 0;
}
int sbs_char_equal_CI(const char A, const char B)
{
char a = tolower(A);
char b = tolower(B);
if (a > b)
return 1;
if (a < b)
return -1;
return 0;
}
char *sbs_find_insert_point_partial(char *old_tail, const char *new_start, size_t n, const int maxerr, int *errcount)
{
const int PARTIAL_CHANGE_LENGTH_MIN = 7;
const int FEW_ERRORS_RATE = 10;
#ifdef DEBUG_SBS
char fmtbuf[20000];
#endif
int few_errors = maxerr / FEW_ERRORS_RATE;
size_t len_r = n / 2;
size_t len_l = n - len_r;
int dist_l = -1;
int dist_r = -1;
int partial_shift;
dist_l = levenshtein_dist_char(old_tail, new_start, len_l, len_l);
dist_r = levenshtein_dist_char(old_tail + len_l, new_start + len_l, len_r, len_r);
*errcount = dist_r + dist_l;
if (dist_l + dist_r > maxerr)
{
/*
#ifdef DEBUG_SBS
sprintf(fmtbuf, "SBS: sbs_find_insert_point_partial: compare\n\
\tnot EQ: [TRUE]\n\
\tmaxerr: [%%d]\n\
\tL buffer: [%%.%zus]\n\
\tL string: [%%.%zus]\n\
\tL dist_l: [%%d]\n\
\tR buffer: [%%.%zus]\n\
\tR string: [%%.%zus]\n\
\tR dist_r: [%%d]\n\
",
len_l,
len_l,
len_r,
len_r
);
LOG_DEBUG(fmtbuf,
maxerr,
old_tail,
new_start,
dist_l,
old_tail + len_l,
new_start + len_l,
dist_r
);
#endif
*/
return NULL;
};
if (
dist_r <= few_errors // right part almost the same
&& n > PARTIAL_CHANGE_LENGTH_MIN // the sentence is long enough for analysis
)
{
/*
LOG_DEBUG("SBS: sbs_find_insert_point_partial: LEFT CHANGED,\n\tbuf:[%s]\n\tstr:[%s]\n\
\tmaxerr:[%d]\n\
\tdist_l:[%d]\n\
\tdist_r:[%d]\n\
",
old_tail,
new_start,
maxerr,
dist_l,
dist_r
);
*/
// searching for first mismatched symbol at the end of buf
// This is a naive implementation of error detection
//
// Will travel from the end of string to the beginning, and
// compare OLD value (from buffer) and new value (new STR)
partial_shift = 0;
while (
old_tail[partial_shift] != 0 && old_tail[partial_shift + 1] != 0 && (0 != sbs_char_equal_CI(old_tail[partial_shift], new_start[partial_shift])))
{
partial_shift += 1;
}
// LOG_DEBUG("SBS: sbs_find_insert_point_partial: PARTIAL SHIFT, [%d]\n",
// partial_shift
// );
return old_tail + partial_shift;
}
/*
#ifdef DEBUG_SBS
sprintf(fmtbuf, "SBS: sbs_find_insert_point_partial: REPLACE ENTIRE TAIL !!\n\
\tmaxerr: [%%d]\n\
\tL buffer: [%%.%zus]\n\
\tL string: [%%.%zus]\n\
\tL dist_l: [%%d]\n\
\tR buffer: [%%.%zus]\n\
\tR string: [%%.%zus]\n\
\tR dist_r: [%%d]\n\
",
len_l,
len_l,
len_r,
len_r
);
LOG_DEBUG(fmtbuf,
maxerr,
old_tail,
new_start,
dist_l,
old_tail + len_l,
new_start + len_l,
dist_r
);
#endif
*/
return old_tail;
}
char *sbs_find_insert_point(char *buf, const char *str, int *ilen)
{
int maxerr;
size_t buf_len;
unsigned char *buffer_tail;
const unsigned char *prefix = (unsigned char *)str;
int cur_err = 0;
unsigned char *cur_ptr;
int cur_len;
int best_err;
unsigned char *best_ptr;
int best_len;
buf_len = strlen(buf);
cur_len = strlen(str);
if (buf_len < cur_len)
cur_len = buf_len;
// init errcounter with value, greater than possible amount of errors in string
best_err = cur_len + 1;
best_ptr = NULL;
best_len = 0;
while (cur_len > 0)
{
maxerr = cur_len / 5;
buffer_tail = buf + buf_len - cur_len;
cur_ptr = sbs_find_insert_point_partial(buffer_tail, prefix, cur_len, maxerr, &cur_err);
if (NULL != cur_ptr)
{
if ((cur_len - cur_err) >= (best_len - best_err))
{
best_err = cur_err;
best_len = cur_len;
best_ptr = cur_ptr;
}
}
cur_len--;
}
*ilen = best_len;
return best_ptr;
}
void sbs_strcpy_without_dup(const unsigned char *str, sbs_context_t *context)
{
int intersect_len;
unsigned char *buffer_insert_point;
unsigned long sbs_len;
sbs_len = strlen(context->buffer);
LOG_DEBUG("SBS: sbs_strcpy_without_dup: going to append, looking for common part\n\
\tbuffer: [%p][%s]\n\
\tstring: [%s]\n\
",
context->buffer,
context->buffer,
str);
buffer_insert_point = sbs_find_insert_point(context->buffer, str, &intersect_len);
LOG_DEBUG("SBS: sbs_strcpy_without_dup: analyze search results\n\
\t buffer: [%s]\n\
\t string: [%s]\n\
\t insert point: ->[%s]\n\
\t intersection len[%4d]\n\
\t sbslen [%4ld]\n\
\t handled len [%4zu]\n\
",
context->buffer,
str,
buffer_insert_point,
intersect_len,
sbs_len,
context->handled_len);
if (intersect_len > 0)
{
// there is a common part (suffix of old sentence equals to prefix of new str)
//
// remove dup from buffer
// we will use an appropriate part from the new string
//context->buffer[sbs_len-intersect_len] = 0;
LOG_DEBUG("SBS: sbs_strcpy_without_dup: cut buffer by insert point\n");
*buffer_insert_point = 0;
}
// check, that new string does not contain data, from
// already handled sentence:
if ((sbs_len - intersect_len) >= context->handled_len)
{
// there is no intersection.
// It is time to clean the buffer. Excepting the last uncomplete sentence
LOG_DEBUG("SBS: sbs_strcpy_without_dup: DROP parsed part\n\
\t buffer: [%s]\n\
\t handled len [%4zu]\n\
\t new start at ->[%s]\n\
",
context->buffer,
context->handled_len,
context->buffer + context->handled_len);
// skip leading whitespaces:
int skip_ws = context->handled_len;
while (isspace(context->buffer[skip_ws]))
{
skip_ws++;
}
strcpy(context->buffer, context->buffer + skip_ws);
context->handled_len = 0;
}
sbs_len = strlen(context->buffer);
if (
!isspace(str[0]) // not a space char in the beginning of new str
//&& context->handled_len >0 // buffer is not empty (there is uncomplete sentence)
&& sbs_len > 0 // buffer is not empty (there is uncomplete sentence)
&& !isspace(context->buffer[sbs_len - 1]) // not a space char at the end of existing buf
)
{
strcat(context->buffer, " ");
}
strcat(context->buffer, str);
}
/**
* Appends the function to the sentence buffer, and returns a list of full sentences (if there are any), or NULL
*
* @param str Partial (or full) sub to append.
* @param time_from Starting timestamp
* @param time_trim Ending timestamp
* @param context Encoder context
* @return New <struct cc_subtitle *> subtitle, or NULL, if <str> doesn't contain the ending part of the sentence. If there are more than one sentence, the remaining sentences will be chained using <result->next> reference.
*/
struct cc_subtitle *sbs_append_string(unsigned char *str, const LLONG time_from, const LLONG time_trim, sbs_context_t *context)
{
struct cc_subtitle *resub;
struct cc_subtitle *tmpsub;
unsigned char *bp_current;
unsigned char *bp_last_break;
unsigned char *sbs_undone_start;
int required_capacity;
int new_capacity;
LLONG alphanum_total;
LLONG alphanum_cur;
LLONG anychar_total;
LLONG anychar_cur;
LLONG duration;
LLONG available_time;
int use_alphanum_counters;
if (!str)
return NULL;
LOG_DEBUG("SBS: sbs_append_string: after sbs init:\n\
\tsbs ptr: [%p]\n\
",
context);
LOG_DEBUG("SBS: sbs_append_string: after sbs init:\n\
\tsbs ptr: [%p][%s]\n\
\tcur cap: [%zu]\n\
",
context->buffer,
context->buffer,
context->capacity);
sbs_str_autofix(str);
// ===============================
// grow sentence buffer
// ===============================
required_capacity =
strlen(context->buffer) // existing data in buf
+ strlen(str) // length of new string
+ 1 // trailing \0
+ 1 // space control (will add one space , if required)
;
if (required_capacity >= context->capacity)
{
LOG_DEBUG("SBS: sbs_append_string: REALLOC BUF:\n\
\tsbs ptr: [%p]\n\
\tcur cap: [%zu]\n\
\treq cap: [%d]\n\
",
context->buffer,
context->capacity,
required_capacity);
new_capacity = context->capacity;
while (new_capacity < required_capacity)
{
// increase NEW_capacity, and check, that increment
// is less than 8 Mb. Because 8Mb - it is a lot
// for a TEXT buffer. It is weird...
new_capacity += (new_capacity > 1048576 * 8)
? 1048576 * 8
: new_capacity;
}
context->buffer = (unsigned char *)realloc(
context->buffer,
new_capacity * sizeof(/*unsigned char*/ context->buffer[0]));
if (!context->buffer)
fatal(EXIT_NOT_ENOUGH_MEMORY, "In sbs_append_string: Not enough memory to append buffer");
context->capacity = new_capacity;
LOG_DEBUG("SBS: sbs_append_string: REALLOC BUF DONE:\n\
\tsbs ptr: {%p}\n\
\tcur cap: [%zu]\n\
\treq cap: [%d]\n\
\tbuf: [%s]\n\
",
context->buffer,
context->capacity,
required_capacity,
context->buffer);
}
// ===============================
// append to buffer
//
// will update buffer, handled_len
// ===============================
sbs_strcpy_without_dup(str, context);
// ===============================
// break to sentences
// ===============================
resub = NULL;
tmpsub = NULL;
alphanum_total = 0;
alphanum_cur = 0;
anychar_total = 0;
anychar_cur = 0;
sbs_undone_start = context->buffer + context->handled_len;
bp_last_break = sbs_undone_start;
LOG_DEBUG("SBS: BEFORE sentence break.\n\
\tLast break: [%s]\n\
\tsbs_undone_start: [%zu]\n\
\tsbs_undone: [%s]\n\
",
bp_last_break,
context->handled_len,
sbs_undone_start);
for (bp_current = sbs_undone_start; bp_current && *bp_current; bp_current++)
{
if (
0 < anychar_cur // skip empty!
&& sbs_is_pointer_on_sentence_breaker(bp_last_break, bp_current))
{
// it is new sentence!
tmpsub = malloc(sizeof(struct cc_subtitle));
tmpsub->type = CC_TEXT;
// length of new string:
tmpsub->nb_data =
bp_current - bp_last_break + 1 // terminating '\0'
+ 1 // skip '.'
;
tmpsub->data = strndup(bp_last_break, tmpsub->nb_data - 1);
tmpsub->datatype = CC_DATATYPE_GENERIC;
tmpsub->got_output = 1;
tmpsub->start_time = alphanum_cur;
alphanum_cur = 0;
tmpsub->end_time = anychar_cur;
anychar_cur = 0;
bp_last_break = bp_current + 1;
// tune last break:
while (
*bp_last_break && isspace(*bp_last_break))
{
bp_last_break++;
}
// ???
// tmpsub->info = NULL;
// tmpsub->mode = NULL;
// link with prev sub:
tmpsub->next = NULL;
tmpsub->prev = resub;
if (NULL != resub)
{
resub->next = tmpsub;
}
resub = tmpsub;
}
if (*bp_current && isalnum(*bp_current))
{
alphanum_total++;
alphanum_cur++;
}
anychar_total++;
anychar_cur++;
}
// ===============================
// okay, we have extracted several sentences, now we should
// save the position of the "remainder" - start of the last
// incomplete sentence
// ===============================
if (bp_last_break != sbs_undone_start)
{
context->handled_len = bp_last_break - sbs_undone_start;
}
LOG_DEBUG("SBS: AFTER sentence break:\
\n\tHandled Len [%4zu]\
\n\tAlphanum Total [%4ld]\
\n\tOverall chars [%4ld]\
\n\tSTRING:[%s]\
\n\tBUFFER:[%s]\
\n",
context->handled_len,
alphanum_total,
anychar_total,
str,
context->buffer);
// ===============================
// Calculate time spans
// ===============================
if ((0 > context->time_from) && (0 > context->time_trim))
{
context->time_from = time_from;
context->time_trim = time_trim;
}
available_time = time_trim - context->time_from;
use_alphanum_counters = alphanum_total > 0 ? 1 : 0;
tmpsub = resub;
while (tmpsub)
{
alphanum_cur = tmpsub->start_time;
anychar_cur = tmpsub->end_time;
if (use_alphanum_counters)
{
duration = available_time * alphanum_cur / alphanum_total;
}
else
{
duration = available_time * anychar_cur / anychar_total;
}
tmpsub->start_time = context->time_from;
tmpsub->end_time = tmpsub->start_time + duration;
context->time_from = tmpsub->end_time + 1;
tmpsub = tmpsub->next;
}
return resub;
}
struct cc_subtitle *reformat_cc_bitmap_through_sentence_buffer(struct cc_subtitle *sub, struct encoder_ctx *context)
{
// this is a sub with a full sentence (or chain of such subs)
struct cc_subtitle *resub = NULL;
#ifdef ENABLE_OCR
struct cc_bitmap *rect;
LLONG ms_start, ms_end;
int i = 0;
char *str;
if (sub->flags & SUB_EOD_MARKER)
{
// the last sub from input
if (context->prev_start == -1)
{
ms_start = 1;
ms_end = sub->start_time;
}
else
{
ms_start = context->prev_start;
ms_end = sub->start_time;
}
}
else
{
// not the last sub from input
ms_start = sub->start_time;
ms_end = sub->end_time;
}
if (sub->nb_data == 0)
return 0;
if (sub->flags & SUB_EOD_MARKER)
context->prev_start = sub->start_time;
str = paraof_ocrtext(sub, context);
if (str)
{
LOG_DEBUG("SBS: reformat_cc_bitmap: string is not empty\n");
if (context->prev_start != -1 || !(sub->flags & SUB_EOD_MARKER))
{
resub = sbs_append_string(str, ms_start, ms_end, sbs_init_context());
}
freep(&str);
}
for (i = 0, rect = sub->data; i < sub->nb_data; i++, rect++)
{
freep(&rect->data0);
freep(&rect->data1);
}
#endif
sub->nb_data = 0;
freep(&sub->data);
return resub;
}
| [
"malcolm@avcomm.com.au"
] | malcolm@avcomm.com.au |
b3fa4e3b4136e05666ccb155d6104d407c7b828e | 16a76ee66d9b2f59c9beee4a4a0e104ce347e32a | /malware_via_email/malware_1036/ia32_pe/by_reko.c | ebaf6eecc03db3d950598b21da780b166c9a97c9 | [] | no_license | rfalke/decompiler-subjects | 4cee3263fa9116285b4bc4b6373efd2e4efa925f | 7187fa93b285c32325826eecd0128e907a28809b | refs/heads/master | 2023-08-10T08:24:27.198393 | 2023-07-28T19:44:41 | 2023-07-28T19:44:41 | 3,725,678 | 41 | 12 | null | 2023-03-15T16:14:41 | 2012-03-15T06:01:36 | null | UTF-8 | C | false | false | 62,111 | c | // subject.c
// Generated by decompiling subject.exe
// using Reko decompiler version VERSION
#include "subject.h"
// 0040686E: Register DWORD Win32CrtStartup()
DWORD Win32CrtStartup()
{
Win32CrtStartup_entry:
esp = fp
v3 = (cl & 0x04) != 0x00
cl = __rol(cl, 0x06)
v6 = (edi & 0x01 << 0x20 - cl) != 0x00
edi = __rol(edi, cl)
C = v6
v8 = (dl & 0x00) != 0x00
dl = __rcl(dl, 0x1D, C)
ch = ch + 0x7C
ebx = ebx | 1799661295
bh = SLICE(ebx, byte, 8) (alias)
bl = (byte) ebx (alias)
ch = dl
ecx = DPB(ecx, ch, 8) (alias)
cx = DPB(cx, ch, 8) (alias)
bh = ~bh
esi = esi << 0x1B
cl_esi = SEQ(cl, esi) (alias)
bh = bh << cl
ebx = DPB(ebx, bh, 8) (alias)
bx = DPB(bx, bh, 8) (alias)
ch_ebx = DPB(ch_ebx, bh, 8) (alias)
cl_bh = SEQ(cl, bh) (alias)
al = al & 0x12
eax = DPB(eax, al, 0) (alias)
ax = DPB(ax, al, 0) (alias)
SZO = cond(al)
v17 = (dl & 0x01 << 0x08 - cl) != 0x00
dl = __rol(dl, cl)
edx = DPB(edx, dl, 0) (alias)
dx = DPB(dx, dl, 0) (alias)
C = v17
bx = bx + 0x01
v19 = (edi & 0x00040000) != 0x00
edi = __rol(edi, 0x0E)
dl = ah
ch = ch | cl
bh = bh >>u cl
cl = -cl
bl = bl | dh
al = al + dh
SCZO = cond(al)
edi = edi - 0x01
SZO = cond(edi)
v23 = (cl & 0x00) != 0x00
cl = __rcr(cl, 0x1B, C)
C = v23
ch = ch - 0x13 - C
SCZO = cond(ch)
goto l00406813
l00406134:
l00406146:
esp = esp - 0x04
Mem0[esp + 0x00:word32] = ebp
eax = eax + 0x9A960000
SCZO = cond(eax)
dl = dl & 0x6B
SZO = cond(dl)
C = false
goto l004066A2
l0040614E:
l0040616C:
branch Test(PO,P) l004061BA
l0040616E:
v126 = Mem0[es:ebx + 0x00:word32] >>u 0x66
Mem0[es:ebx + 0x00:word32] = v126
SCZO = cond(v126)
goto l00406172
l00406171:
l00406172:
edx = edx - 1322522491 - C
dh = dh | 0x5E
C = false
ecx = ecx - 0x4C144A38 - C
v49 = (ch & 0x80) != 0x00
ch = __rol(ch, 0x01)
C = v49
bh = bh + cl + C
cl = cl & ch
bx = bx << cl
SCZO = cond(bx)
edx = edx | ~0x113C800A
v54 = (al & 0x00) != 0x00
al = __ror(al, 0x17)
ecx = ecx - 0x01
ebx = ebx | esi
ah = ah - ch
bh = bh << cl
SCZO = cond(ebx - 3542656288)
branch Test(NE,Z) l00406463
goto l00406755
l00406196:
l004061A0:
ch = ch >> 11
v135 = (edi & 0x00100000) != 0x00
edi = __ror(edi, 0x14)
eax = 0x00
v136 = (ch & 0x00) != 0x00
ch = __rol(ch, 0x11)
cl = cl + 0x67
SCZO = cond(edx - 0x513B51C0)
branch Test(NE,Z) l004065F2
l004061BA:
branch Test(LT,SO) l00406146
l004061BC:
esp = esp - 0x01
eax = eax & 3936636773
SZO = cond(eax)
C = false
l004061C2:
eax = eax >> cl
ebx = ebx + 382054440
SCZO = cond(ebx)
v130 = (ah & 0x02) != 0x00
ah = __rcl(ah, 0x07, C)
eax = eax - 0x25A84459
edi = edi - 1145540307
ebx = ebx | 0x10A74EDA
bx = bx | si
ecx = ecx >>u cl
SCZO = cond(ecx)
bl = bl + 141 + C
SCZO = cond(bl)
eax = eax >>u 0x15
ch = ch >>u 22
cx = cx + si
ah = ah | cl
C = false
v132 = (bh & 0x00) != 0x00
bh = __rcl(bh, 0x09, C)
C = v132
bl = bl + ch + C
ebx = ebx + 0x91850546
SCZO = cond(ebx)
bx = ~bx
v133 = (ch & 0x01 << 0x08 - cl) != 0x00
ch = __rol(ch, cl)
ah = ah | 202
dl = dl ^ al
SZO = cond(dl)
v134 = (cl & 0x00) != 0x00
cl = __ror(cl, 0x12)
C = v134
goto l004061A0
l004061F4:
l00406218:
eax = eax + 2130275801
SCZO = cond(eax)
branch ecx == 0x00 l004061A0
l0040621F:
call Mem0[edx + 0x00:word32] (retsize: 4;)
ebp = ebp - 0x01
dl = dl + cl + C
SCZO = cond(dl)
v142 = (esi & 0x00080000) != 0x00
esi = __rcr(esi, 0x13, C)
eax = eax - 0x01
eax = eax << 0x07
bh = bh + dh
cl = cl & ~0x0A
dx = di
dl = dl ^ 212
C = false
v143 = (cl & 0x01 << 0x08 - cl) != 0x00
cl = __rcl(cl, cl, C)
bl = bl >> cl
SCZO = cond(edi - 3035650863)
branch Test(NE,Z) l00406932
l00406246:
Mem0[edi + 0x00:word32] = __in(dx)
edi = edi + 0x04
eax = eax + 0x85D087C4
eax = eax | 0xC004C9C1
SZO = cond(eax)
C = false
goto l00406251
l0040624D:
v86 = (ecx & 0x10) != 0x00
ecx = __ror(ecx, 0x04)
C = v86
v87 = (cl & 0x00) != 0x00
cl = __rcr(cl, 0x1A, C)
C = v87
l00406251:
bh = bh - bl
bh = 114
C = false
ax = gs
esi = esi - 1419619889 - C
ebx = ebx & 4218906929
SZO = cond(ebx)
C = false
cx = cx - 0x01
ebx = ebx << cl
SCZO = cond(ebx)
esi = esi + eax + C
bh = -bh
C = bh == 0x00
edi = edi + 553365444 + C
v91 = (bl & 0x01 << 0x08 - cl) != 0x00
bl = __rol(bl, cl)
SCZO = cond(esi - 222013019)
branch Test(NE,Z) l004065C6
goto l0040690F
l00406290:
l004062B8:
l004062E4:
esp = esp << ~0x01
eax = eax & 0x666D0B89
SZO = cond(eax)
C = false
goto l004062EC
l004062EB:
cx = bx
l004062EC:
ch = ch << 0x14
v100 = (bl & 0x00) != 0x00
bl = __rol(bl, 0x14)
cx = -cx
si = si | ax
C = false
v101 = (bh & 0x00) != 0x00
bh = __rcl(bh, 0x0E, C)
ebx = ebx << 0x08
v102 = (ch & 0x02) != 0x00
ch = __rol(ch, 0x07)
SCZO = cond(esi - 3078822012)
branch Test(NE,Z) l004069AB
l0040630F:
eax = eax + edi[esi * 0x04] + C
SCZO = cond(eax)
eax = eax - 0x01
SZO = cond(eax)
branch Test(SG,S) l00406351
l00406315:
l00406317:
l0040633A:
al = al | 0x00
edi = edi + 0x01
v118 = (Mem0[eax + 0x00:byte] & 0x00) != 0x00
Mem0[eax + 0x00:byte] = __rol(Mem0[eax + 0x00:byte], 0x5D)
C = v118
al = al + 0x93 + C
dl = dl ^ 0x00
SZO = cond(ebx & 227261754)
C = false
l0040634D:
ecx = ecx | 0xFB1CB015
SZO = cond(ecx)
C = false
goto l00406353
l00406351:
al = al - ~0x04 - C
SCZO = cond(al)
l00406353:
bh = -bh
ecx = ecx << 0x19
esi = esi | 0x7C01C71B
si = si + cx
SCZO = cond(si)
v110 = (ecx & 0x00010000) != 0x00
ecx = __rcr(ecx, 0x10, C)
C = v110
edi = edi + 0x4BE0B05E + C
ch = ch ^ 0x0D
cl = cl >>u cl
SCZO = cond(cl)
v113 = (ebx & 0x01 << cl) != 0x00
ebx = __rcr(ebx, cl, C)
v114 = (ebx & 0x40000000) != 0x00
ebx = __ror(ebx, 0x1E)
edi = edi << 0x12
bh = bh >>u 0x15
edi = edi - 0x01
bl = bl << 0x07
SCZO = cond(ebx - 3055327238)
branch Test(NE,Z) l0040697F
goto l004062E4
l00406399:
l004063BE:
l004063DC:
edi = edi ^ 0x670FA308
cl = cl & 0x18
bh = bh ^ 0x31
C = false
cl = cl + ah + C
SCZO = cond(cl)
bl = bl + dh + C
v61 = (bx & 0x01 << cl) != 0x00
bx = __ror(bx, cl)
C = v61
cl = cl + 0x01
SZO = cond(cl)
bh = bh + ch
ecx = ecx >>u cl
ebx = ebx >>u 0x15
ecx = ecx ^ 3483220632
bl = bl | ~0x30
cx = di
di = ~di
SCZO = cond(ecx - 3799286827)
branch Test(NE,Z) l0040624D
goto l0040670E
l004063FA:
ecx = ecx + 0x01
bx = bx ^ ax
v144 = (cl & 0x01 << 0x08 - cl) != 0x00
cl = __rol(cl, cl)
C = v144
di = di - cx - C
ecx = ecx - 797772582
SCZO = cond(ecx)
v145 = (esi & 0x04000000) != 0x00
esi = __rcl(esi, 0x06, C)
edi = edi + ebx
esi = esi ^ 272790877
SZO = cond(esi)
C = false
__syscall(0x2E)
goto l004066C5
l00406441:
l00406463:
v58 = (edi & 0x0400) != 0x00
edi = __rol(edi, 22)
ecx = 0xB15CAD04
dx = ~dx
v59 = (dl & 0x00) != 0x00
dl = __ror(dl, 0x15)
C = v59
v60 = true
ecx = __rcr(0xB15CAD04, 0x0F, C)
al = al & bh
di = di - si
dh = dh | ch
SZO = cond(dh)
C = false
ecx = ecx ^ 2255393096
C = false
al = al - 0x01
ch = ch + ah + C
SCZO = cond(ch)
v62 = (ebx & 0x08000000) != 0x00
ebx = __rcl(ebx, 0x05, C)
ecx = ecx + ~0x714F3234
edi = edi << 0x17
SCZO = cond(edi)
goto l00406565
l00406486:
bh = 0x34
bl = bl & cl
cx = cx << cl
ebx = 2885363933
ecx = ecx ^ 2329383665
SCZO = cond(edx - 30008482)
branch Test(NE,Z) l0040634D
l004064A4:
v122 = (ecx & 0x08000000) != 0x00
ecx = __rol(ecx, 0x05)
cl = cl | 0x3E
SCZO = cond(edi - 98757798)
branch Test(NE,Z) l004064B6
l004064B2:
dl = dl & bl
SCZO = cond(Mem0[esi + 0x00:byte] - Mem0[edi + 0x00:byte])
esi = esi + 0x01
edi = edi + 0x01
branch Test(NE,Z) l0040651D
goto l004064B7
l004064B6:
di = -di
SCZO = cond(di)
C = di == 0x00
goto l004064B9
l004064B7:
edi = -edi
SCZO = cond(edi)
C = edi == 0x00
l004064B9:
dh = dh << cl
SCZO = cond(dh)
v123 = (esi & 0x01 << cl) != 0x00
esi = __rcr(esi, cl, C)
C = v123
v124 = (dx & 0x01 << cl) != 0x00
dx = __rcr(dx, cl, C)
C = v124
cl = 155
return eax
l004064D4:
ch = ch + ah
esi = esi ^ 1214030043
v108 = (ebx & 0x2000) != 0x00
ebx = __ror(ebx, 0x0D)
edi = edi >>u cl
bl = ~bl
ecx = ecx - 3137023338
edx = edx + 0x01
SZO = cond(edx)
v109 = (ebx & 0x10) != 0x00
ebx = __rol(ebx, 0x1C)
C = v109
v111 = (ch & 0x00) != 0x00
ch = __rcl(ch, 0x0C, C)
ch = ch << 0x0D
SCZO = cond(ch)
bl = 0x93
ebx = ebx + 0xE2A5F200 + C
bh = bh + ~0x52
SCZO = cond(bh)
cl = cl + al + C
SCZO = cond(cl)
si = si - ax - C
cl = cl >> 0x07
SCZO = cond(cl)
v112 = (ch & 0x01 << cl) != 0x00
ch = __ror(ch, cl)
C = v112
edi = 2510251913
v115 = (ch & 0x00) != 0x00
ch = __rcl(ch, 0x0D, C)
cx = -cx
cl = cl << 0x11
cl = cl & 0x23
ecx = ecx >>u 0x06
v116 = (cl & 0x10) != 0x00
cl = __ror(cl, 0x04)
bl = bl - 0xC2
v117 = (bl & 0x01 << 0x08 - cl) != 0x00
bl = __rol(bl, cl)
SCZO = cond(eax - 2742595023)
branch Test(NE,Z) l00406486
goto l0040633A
l004064F7:
l00406515:
l0040651D:
al = 0x00
SZO = cond(0x00)
C = false
goto l0040651F
l0040651E:
l0040651F:
v128 = (edx & 0x40) != 0x00
edx = __rol(edx, 0x1A)
C = v128
bl = bl | 118
SZO = cond(bl)
C = false
goto Win32CrtStartup_exit
l00406522:
return eax
l00406524:
l00406535:
bh = bh << cl
bl = bl << cl
SCZO = cond(bl)
edi = edi - 0xA0A62968 - C
esi = esi | 2520014028
C = false
cl = cl - 0x01
bl = bl - ~0x0E - C
bh = bh >>u cl
si = si << cl
bh = bh & 151
bl = bl << 0x1D
SCZO = cond(esi - 3830412171)
branch Test(NE,Z) l00406835
l00406561:
al = Mem0[esi + 0x00:byte]
esi = esi + 0x01
ecx = ecx - 0x01
SZO = cond(ecx)
v93 = eax
eax = edi
edi = v93
__outw(dx, ax)
l00406565:
bl = bl >> cl
eax = eax >>u 0x1C
ecx = ebx
edi = edi << cl
al = al >>u cl
dh = dh & 113
C = false
v65 = (al & 0x01 << cl) != 0x00
al = __rcr(al, cl, C)
cl = cl + bh
ebx = ebx + 0xAD8C13EA
SCZO = cond(edx - 2997538953)
branch Test(NE,Z) l00406589
l00406585:
dh = dh
ecx = ecx - 0x01
branch Test(NE,Z) && ecx != 0x00 l00406522
l00406589:
ebx = ebx + ecx
edx = edx | 4233624337
ecx = ecx - 2611141272
edi = edi ^ 3886238279
al = al | dl
SZO = cond(ebx & esi)
C = false
dh = dh << cl
v70 = (ebx & 0x00200000) != 0x00
ebx = __ror(ebx, 0x15)
C = v70
bh = bh + 0x59 + C
v71 = (bx & 0x01 << 0x10 - cl) != 0x00
bx = __rol(bx, cl)
ecx = ecx + 0xF979F010
SCZO = cond(ecx)
v72 = (ch & 0x00) != 0x00
ch = __rcr(ch, 0x1A, C)
C = v72
di = di >>u cl
v75 = (dh & 0x00) != 0x00
dh = __rol(dh, 0x0C)
ah = ah >> 0x05
bh = bh >>u cl
edx = edx << 0x12
bl = bl | al
bh = bh ^ 0x87
C = false
v76 = (dl & 0x01 << cl) != 0x00
dl = __rcr(dl, cl, C)
SCZO = cond(edx - 0x8924C248)
branch Test(NE,Z) l004068D4
l004065AA:
edx = edx - 3572220853
ah = ah << 0x0C
SCZO = cond(ah)
v119 = (edx & 0x01 << cl) != 0x00
edx = __rcr(edx, cl, C)
C = v119
v120 = (eax & 0x01 << cl) != 0x00
eax = __rcr(eax, cl, C)
C = v120
dl = dl - ch - C
edi = edi | edx
SZO = cond(edi)
C = false
bx = -bx
SZO = cond(edx & 811680376)
C = false
v127 = (ah & 0x00) != 0x00
ah = __rol(ah, 0x13)
C = v127
goto l0040651F
l004065C6:
esi = esi ^ 0x4366BB7B
ecx = ecx | 712997852
v97 = (cl & 0x01 << cl) != 0x00
cl = __ror(cl, cl)
C = v97
v98 = (edi & 0x40) != 0x00
edi = __rcl(edi, 0x1A, C)
edi = edi + edx
v99 = (ch & 0x00) != 0x00
ch = __ror(ch, 0x0E)
SCZO = cond(edi - 0x58959644)
branch Test(NE,Z) l004067BA
l004065ED:
__outb(dx, al)
esi = esi + 0x01
ecx = ecx + 0x01
SZO = cond(ecx)
l004065F2:
v137 = (si & 0x01 << 0x10 - cl) != 0x00
si = __rcl(si, cl, C)
C = v137
v138 = (bl & 0x01 << cl) != 0x00
bl = __rcr(bl, cl, C)
edi = edi << 0x1E
edx = edx + eax
bh = bh - 0x01
bl = bl - 0xAA
SCZO = cond(bl)
dh = dh << cl
v139 = (dh & 0x01 << cl) != 0x00
dh = __ror(dh, cl)
v140 = (bh & 0x00) != 0x00
bh = __rol(bh, 0x1A)
edx = edx - 0x95D8CB80
ecx = ecx >> 0x04
si = si - 0x01
edx = edx ^ eax
C = false
v141 = (ch & 0x01 << 0x08 - cl) != 0x00
ch = __rcl(ch, cl, C)
ch = ch << cl
SCZO = cond(edx - 3777187378)
branch Test(NE,Z) l004063FA
goto l00406218
l0040660C:
ch = ch >> cl
ecx = ecx | 798490029
C = false
bl = bl - 0x0D - C
SCZO = cond(bl)
dh = ah
bh = ~bh
v66 = (ch & 0x00) != 0x00
ch = __rcr(ch, 22, C)
ecx = ecx - 1834284232
SCZO = cond(edi - 1040570817)
branch Test(NE,Z) l0040679E
l00406630:
eax = eax + 0x01
Mem0[edi + 0x00:word32] = __in(dx)
edi = edi + 0x04
dh = dh + Mem0[eax + 0x2A:byte] + C
SCZO = cond(dh)
v67 = (bh & 0x01 << 0x08 - cl) != 0x00
bh = __rol(bh, cl)
C = v67
l00406636:
v68 = (eax & 0x08) != 0x00
eax = __rol(eax, 0x1D)
v69 = (bh & 0x04) != 0x00
bh = __ror(bh, 0x02)
dx = dx << cl
edi = -edi
C = edi == 0x00
dx = dx - 0x01
SZO = cond(dx)
goto l0040677E
l00406650:
l00406672:
l0040669B:
v105 = eax
eax = esp
esp = v105
v106 = Mem0[edx + 1810006107:byte] ^ dl
Mem0[edx + 1810006107:byte] = v106
SZO = cond(Mem0[edx + 1810006107:byte])
C = false
goto l004066A2
l0040669F:
l004066A2:
v89 = (edx & 0x01 << 0x20 - cl) != 0x00
edx = __rcl(edx, cl, C)
v90 = (ebx & 0x1000) != 0x00
ebx = __rol(ebx, 0x14)
dx = dx + bx
edi = edi << 0x17
ecx = ecx + 549649986
bh = bh & ~0x25
edx = 0x00
SZO = cond(0x00)
C = false
ch = ch - 0x5C - C
esi = esi | 2233940752
bl = bl << 0x02
bh = -bh
v92 = (bh & 0x01 << cl) != 0x00
bh = __ror(bh, cl)
C = v92
ebx = ebx + 2012625022 + C
SCZO = cond(ebx)
v94 = (ebx & 0x01 << 0x20 - cl) != 0x00
ebx = __rol(ebx, cl)
esi = esi >> cl
SCZO = cond(esi)
bl = bl + 0x70 + C
ch = ch - dh
SCZO = cond(ch)
v95 = (ch & 0x01 << 0x08 - cl) != 0x00
ch = __rcl(ch, cl, C)
gs = ax
ecx = ecx >> 0x05
v96 = (esi & 0x01 << cl) != 0x00
esi = __ror(esi, cl)
C = v96
cl = cl + ~0x28 + C
SCZO = cond(cl)
edi = edi & 2004609509
C = false
edi = edi + 0x01
ebx = ebx + 0x7887F75C + C
ch = ch >> cl
v103 = (di & 0x01 << cl) != 0x00
di = __ror(di, cl)
C = v103
v104 = (si & 0x01 << cl) != 0x00
si = __rcr(si, cl, C)
bh = bh | dl
bl = bl & bh
di = di - 0x01
ch = ch << cl
SCZO = cond(eax - 0x3BD3A35F)
branch Test(NE,Z) l0040675B
goto l0040669B
l004066C3:
eax = eax - 3956459539
SCZO = cond(eax)
l004066C5:
edi = edi + ebx + C
esi = esi & 1064770127
v77 = (edi & 0x01 << 0x20 - cl) != 0x00
edi = __rol(edi, cl)
di = di >> cl
esi = esi >>u 0x1D
SCZO = cond(esi)
v78 = (dh & 0x00) != 0x00
dh = __ror(dh, 0x12)
v79 = (dl & 0x00) != 0x00
dl = __ror(dl, 0x19)
C = v79
goto l00406715
l004066E6:
l0040670E:
branch Test(NS,S) l004066C3
l00406710:
dh = 242
v64 = (Mem0[~0x09207AAF:byte] & 0x01 << cl) != 0x00
Mem0[~0x09207AAF:byte] = __ror(Mem0[~0x09207AAF:byte], cl)
C = v64
l00406715:
return eax
l00406739:
l00406755:
__outb(~0x05, al)
v55 = Mem0[ecx + 0x04:word32]
Mem0[ecx + 0x04:word32] = esp
esp = v55
v56 = (Mem0[edx + 0x00:word32] & 0x00040000) != 0x00
Mem0[edx + 0x00:word32] = __rcl(Mem0[edx + 0x00:word32], ~0x11, C)
C = v56
l0040675B:
cl = ~0x30
ecx = ecx << ~0x30
cl = cl >> cl
ebx = ebx << 0x0E
edi = edi ^ 331989994
SCZO = cond(edx - 0x38AA808D)
branch Test(NE,Z) l004063DC
l00406778:
ebp = ebp + 0x01
v57 = Mem0[eax + ~0x353E8585:word32] + esp
Mem0[eax + ~0x353E8585:word32] = v57
SCZO = cond(v57)
l0040677E:
ch = ch - Mem0[edx + 0x00:byte] - C
dl = 226
ebx = ~0x2CEF24C4
ecx = ecx - 0x01
dh = 0xD0
cl = cl | 0x18
SCZO = cond(eax - 1447662871)
branch Test(NE,Z) l004067DD
l00406798:
esp = esp - 0x04
Mem0[esp + 0x00:word32] = ~0x34
SCZO = cond(eax - 3234337407)
l0040679E:
v73 = (dh & 0x00) != 0x00
dh = __rcl(dh, 0x18, C)
bh = bh & ch
ch = ch >> 0x0D
SCZO = cond(ch)
v74 = (bh & 0x01 << cl) != 0x00
bh = __rcr(bh, cl, C)
dh = -dh
edx = edx << 0x11
SCZO = cond(edx)
dh = dh - 0x01
di = di + si
bx = bx - ax
di = di >> cl
dh = dh >> cl
SCZO = cond(dh)
edi = edi - esi - C
esi = esi & ebx
SZO = cond(esi)
C = false
l004067BA:
bx = di
cl = cl ^ dh
v107 = (di & 0x01 << cl) != 0x00
di = __ror(di, cl)
bl = bl >>u 0x0F
ebx = ebx + 0x01
si = si >> cl
SCZO = cond(ebx - ~0x25EC3452)
branch Test(NE,Z) l004064D4
l004067D7:
edi = edi - 0x01
C = __aaa(al, ah, &al, &ah)
eax = eax - 0x01
esi = ebx
esi = esi - 0x01
SZO = cond(esi)
l004067DD:
esi = edi
ah = ah << cl
ch = ch + 0x12
ax = dx
al = bh
ebx = ebx >> 0x10
eax = 0x03
cl = cl + dh
ecx = ecx | 3936574597
esi = esi - 2676757123
SCZO = cond(edi - 2477771791)
branch Test(NE,Z) l0040660C
l0040680B:
ecx = ecx - 0x01
SZO = cond(ecx)
eax = 0xDD806289
goto l00406813
l00406811:
l00406813:
v24 = (edi & 0x01 << cl) != 0x00
edi = __ror(edi, cl)
C = v24
v25 = (di & 0x01 << cl) != 0x00
di = __rcr(di, cl, C)
v27 = (ah & 0x01 << 0x08 - cl) != 0x00
ah = __rol(ah, cl)
ebx = ebx >> cl
ch = ch ^ bh
bh = bh - 223
v28 = (edi & 0x8000) != 0x00
edi = __ror(edi, 0x0F)
SCZO = cond(edx - 1374512595)
branch Test(NE,Z) l004068B6
l0040682C:
SZO = cond(Mem0[ebp + 0x19000000:word32] & eax)
C = false
l00406831:
v32 = Mem0[edi - 0x28 + 0x00:word32] - ebp - C
Mem0[edi - 0x28 + 0x00:word32] = v32
SCZO = cond(v32)
l00406832:
ecx = ecx - 0x01
branch Test(EQ,Z) && ecx != 0x00 l0040682C
l00406835:
bh = -bh
SCZO = cond(bh)
C = bh == 0x00
l00406836:
Mem0[edx + 0x00:int16] = (int16) trunc(rArg0)
l00406837:
al = __inb(dx)
edi = edi << 0x1C
esi = esi >> cl
v36 = (esi & 0x0400) != 0x00
esi = __ror(esi, 0x0A)
di = di | si
SZO = cond(di)
C = false
C = fn00407856(al, cx, dl, dh, bx, ebp, si, es, out eax, out ecx, out edx, out ebx, out ebp, out esi, out edi)
goto l004069DD
l0040684C:
l0040686E:
l00406892:
l004068B6:
ah = ah + 0x0A + C
SCZO = cond(ah)
ebx = ebx - ecx - C
edi = -edi
eax = eax >>u 0x1C
SCZO = cond(eax)
al = ch
v39 = (cl & 0x00) != 0x00
cl = __rcl(cl, 0x11, C)
bl = bl - 0x01
SZO = cond(bl)
v40 = (ch & 0x40) != 0x00
ch = __rol(ch, 0x02)
C = v40
dx = dx >>u cl
SCZO = cond(dx)
goto l00406172
l004068D4:
eax = eax >>u 0x01
SCZO = cond(eax)
al = al - dh - C
SCZO = cond(al)
dl = dl + 0x01
dx = dx + 0x01
ebx = ebx - 0x01
al = al - bl - C
SCZO = cond(ecx - 3078188181)
branch Test(NE,Z) l004065AA
l004068EC:
eax = eax - 3253589820 - C
SZO = cond(Mem0[3250752358:word32] & 4150662362)
v121 = (Mem0[ebp + ~0x05749934:word32] & 0x01 << 0x20 - cl) != 0x00
Mem0[ebp + ~0x05749934:word32] = __rol(Mem0[ebp + ~0x05749934:word32], cl)
al = al - 0x88
SCZO = cond(al)
dl = dl - 0x84 - C
bh = bh + 0x69
SCZO = cond(bh)
dh = dh + 0x01
v125 = (edx & 0x00800000) != 0x00
edx = __rcr(edx, 0x17, C)
eax = eax ^ 0xA8C83868
bx = bx - ax
dh = dh & bl
SCZO = cond(ebx - 2209592694)
branch Test(NE,Z) l004061C2
goto l0040616C
l004068F3:
l0040690F:
rArg0 = Mem0[3917550279:real64] - rArg0
eax = eax - 0x01
SZO = cond(eax)
l00406932:
v146 = (esi & 0x00040000) != 0x00
esi = __rcl(esi, 0x0E, C)
eax = eax - 0x01
edi = edi | 3628542615
C = false
bh = bh - ah - C
SCZO = cond(bh)
v147 = (cl & 0x08) != 0x00
cl = __ror(cl, 0x03)
C = v147
v148 = (cx & 0x01 << cl) != 0x00
cx = __rcr(cx, cl, C)
C = v148
goto l00406636
l00406951:
l00406974:
Mem0[edi + 0x00:word32] = ecx
SZO = cond(Mem0[ecx - 0x01 + 0x00:word32] & ebx)
C = false
l00406975:
l00406976:
l0040697B:
v80 = Mem0[esi + 0x00:byte]
Mem0[edi + 0x00:byte] = v80
esi = esi + 0x01
edi = edi + 0x01
v81 = Mem0[ebx + 0x1D:byte] | bl
Mem0[ebx + 0x1D:byte] = v81
SZO = cond(Mem0[ebx + 0x1D:byte])
C = false
l0040697F:
cl = cl >> 0x1B
SCZO = cond(cl)
ch = ch + 0x98 + C
SCZO = cond(ch)
v82 = (eax & 0x02) != 0x00
eax = __ror(eax, 0x01)
C = v82
branch Test(ULT,C) l004063DC
l0040698E:
ch = ch + 0x23 + C
si = si + 0x01
SCZO = cond(eax - 0x405D8093)
branch Test(NE,Z) l004062EB
l004069A5:
Mem0[edi + 0x00:word32] = __in(dx)
edi = edi + 0x04
ebx = 0x403477CE
l004069AB:
bh = bh - 0x99 - C
cl = cl ^ bh
v83 = (bl & 0x01 << 0x08 - cl) != 0x00
bl = __rol(bl, cl)
C = v83
v84 = (ch & 0x08) != 0x00
ch = __rcl(ch, 0x05, C)
C = v84
cl = cl + 55 + C
SCZO = cond(cl)
ecx = ecx - 0xCAAA117A - C
esi = esi - ebx
SCZO = cond(esi)
cl_esi = cl_esi - ch_ebx
v85 = (ebx & 0x0800) != 0x00
ebx = __rol(ebx, 0x15)
SCZO = cond(edi - 3554111384)
branch Test(NE,Z) l00406535
l004069D4:
ch = 0xC0
esp = esp - (esi + 1994923063)[esi * 0x08] - C
SCZO = cond(esp)
goto l004069DD
l004069DB:
l004069DD:
esi = esi + esp + C
SCZO = cond(esi)
branch Test(NS,S) l00406A39
l004069E4:
eax = eax + 0x6CCA0827
SCZO = cond(eax)
es = Mem0[esp + 0x00:selector]
esp = esp + 0x02
branch Test(LT,SO) l00406974
l004069EC:
al = __inb(228)
eax = eax + ~0x194BE742
SCZO = cond(eax)
l004069F3:
eax = eax & 0xE4EC0207
SZO = cond(eax)
C = false
l004069F8:
al = __inb(0xA4)
C = __daa(al, &al)
ebp = ebp | ecx
al = __inb(dx)
al = __inb(228)
C = __aas(al, ah, &al, &ah)
SCZO = cond(al - 0x27)
esp = esp - 0x04
Mem0[esp + 0x00:word32] = SCZDOP
esp = esp - 0x04
Mem0[esp + 0x00:word32] = esi
branch Test(UGE,C) l004069F3
l00406A07:
v45 = eax
eax = ecx
ecx = v45
__outb(0xC9, al)
v46 = (Mem0[edi + 4189186516:byte] & 0x01 << cl) != 0x00
Mem0[edi + 4189186516:byte] = __rcr(Mem0[edi + 4189186516:byte], cl, C)
eax = 0xE4844C0B
al = __inb(141)
esi = Mem0[esp + 0x00:word32]
esp = esp + 0x04
Mem0[0x47BB0D42:byte] = 0x25
es = Mem0[esp + 0x00:selector]
esp = esp + 0x02
dh = ~0x13
al = __inb(228)
v47 = Mem0[esi + 0x00:byte]
Mem0[edi + 0x00:byte] = v47
esi = esi + 0x01
edi = edi + 0x01
C = __daa(al, &al)
eax = eax | 1218050792
eax = eax & 626563578
esi = esi | eax
SZO = cond(ah & ah)
C = false
al = __inb(114)
branch Test(PE,P) l004069F8
l00406A38:
bh = 114
SCZO = cond(eax - 0xA44592A4)
goto l00406A3B
l00406A39:
branch Test(ULT,C) l00406A78
goto l00406A3B
l00406A3A:
l00406A3B:
v50 = eax
eax = edx
edx = v50
al = al ^ 0xA4
v51 = eax
eax = edx
edx = v51
al = al ^ 0x07
SZO = cond(al)
C = false
ax = __aam(al)
al = __inb(228)
es = Mem0[esp + 0x00:selector]
esp = esp + 0x02
esp = esp - 0x04
Mem0[esp + 0x00:word32] = eax
call fn75484F34 (retsize: 4; depth: 4 FPU: -1;)
al = __inb(dx)
al = __inb(228)
bl = Mem0[ecx + ~0x070DAAF8:byte]
v53 = Mem0[esi + 0x00:word32]
Mem0[edi + 0x00:word32] = v53
esi = esi + 0x04
edi = edi + 0x04
al = __inb(228)
al = __inb(0x8A)
call fn179B0EE7 (retsize: 4; depth: 4 FPU: -1;)
return eax
l00406A78:
__hlt()
Win32CrtStartup_exit:
}
// 00407583: FlagGroup bool fn00407583(Register byte cl, Register byte bl, Register word32 ebp, Register word32 esi, Register word32 edi, FpuStack real64 rArg0, Register out ptr32 eaxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut, FpuStack out ptr32 rArg0Out)
bool fn00407583(byte cl, byte bl, word32 ebp, word32 esi, word32 edi, real64 rArg0, ptr32 & eaxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut, ptr32 & rArg0Out)
{
if (CZ)
__hlt();
else
{
word32 eax_13;
word32 ebx_14;
word32 esi_15;
word32 edi_16;
return fn00407589(cl, bl, ebp, esi, edi, out eax_13, out ebx_14, out esi_15, out edi_16);
}
}
// 00407589: FlagGroup bool fn00407589(Register byte cl, Register byte bl, Register word32 ebp, Register word32 esi, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407589(byte cl, byte bl, word32 ebp, word32 esi, word32 edi, ptr32 & eaxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
ptr32 fp;
word32 eax;
byte cl;
byte bl;
word32 ebp;
word32 esi;
word32 edi;
ptr32 eaxOut;
ptr32 ebxOut;
ptr32 esiOut;
ptr32 ediOut;
esp_1 = fp;
al_2 = __inb(228);
al_3 = __inb(242);
eax_5 = DPB(eax, al_3, 0);
eax_6 = eax_5 - ~0x2D300D0B;
esp_8 = fp << cl;
eax_9 = eax_6 - 0x0B2CF2F4;
al_10 = (byte) eax_9;
SCZO_11 = cond(eax_9);
C_12 = (bool) SCZO_11;
C_21 = fn0040759A(al_10, cl, bl, ebp, esi, edi, out eax_17, out ebx_18, out esi_19, out edi_20);
SCZO_22 = DPB(SCZO_11, C_21, 0);
return C_21;
}
// 0040759A: FlagGroup bool fn0040759A(Register byte al, Register byte cl, Register byte bl, Register word32 ebp, Register word32 esi, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn0040759A(byte al, byte cl, byte bl, word32 ebp, word32 esi, word32 edi, ptr32 & eaxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
Mem9[edi + 0x00:byte] = Mem0[esi + 0x00:byte];
Mem14[edi + 0x01:byte] = Mem9[esi + 0x01:byte];
word32 eax_20;
word32 ebx_21;
word32 esi_22;
word32 edi_23;
return fn0040759E(cl, bl, ebp, esi + 0x02, edi + 0x02, out eax_20, out ebx_21, out esi_22, out edi_23);
}
// 0040759E: FlagGroup bool fn0040759E(Register byte cl, Register byte bl, Register word32 ebp, Register word32 esi, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn0040759E(byte cl, byte bl, word32 ebp, word32 esi, word32 edi, ptr32 & eaxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
word32 eax_35;
*eaxOut = edi | Mem0[edi + 0x00:word32];
Mem48[1991550116:byte] = Mem0[esi + 0x00:byte];
Mem52[1991550117:byte] = Mem48[esi + 0x01:byte];
word32 ebx_10;
*ebxOut = DPB(ebx, bl * 0x02, 0);
word32 esi_53;
*esiOut = esi + 0x02;
word32 edi_54;
*ediOut = 1991550118;
if (bl * 0x02 <u 0x00)
{
word32 eax_79;
word32 ebx_80;
word32 esi_81;
word32 edi_82;
real64 rArg0_83;
return fn00407583(cl, bl * 0x02, ebp, esi + 0x02, 1991550118, rArg0, out eax_79, out ebx_80, out esi_81, out edi_82, out rArg0_83);
}
else
{
bool C_74 = (bool) cond(bLoc2DEB2C50 << 0xB2);
fn004075BE(rArg0);
return C_74;
}
}
// 004075BA: FpuStack real64 fn004075BA(Register byte cl, Register word32 edx, FpuStack real64 rArg0)
real64 fn004075BA(byte cl, word32 edx, real64 rArg0)
{
ptr32 fp;
word32 edx;
<type-error> Mem0;
byte cl;
bool C;
real64 rArg0;
word32 ecx;
word32 ebp;
word32 eax;
word32 ebx;
word32 esi;
word32 edi;
esp_1 = fp;
v4_5 = (edx[edx * 0x08] & 0x01 << 0x20 - cl) != 0x00;
edx[edx * 0x08] = __rcl(edx[edx * 0x08], cl, C);
C_8 = v4_5;
dl_9 = 244;
edx_10 = DPB(edx, dl_9, 0);
rArg0_12 = fn004075BE(rArg0);
return rArg0_12;
}
// 004075BE: FpuStack real64 fn004075BE(FpuStack real64 rArg0)
real64 fn004075BE(real64 rArg0)
{
fn004075BE_entry:
def fp
esp_1 = fp
__hlt()
l004075BE:
l004075BE:
al = __inb(11)
rArg0 = rArg0 * (real64) Mem0[(esp - 0x5C) + 0x00:word32]
v6 = ebx
ebx = ebp
ebp = v6
branch Test(NS,S) l004075C7_thunk_fn0040759E
fn004075BE_exit:
}
// 004075D2: FlagGroup bool fn004075D2(Register byte al, Register byte ah, Register word32 ecx, Register byte dh, Register byte dl, Register byte bh, Register word32 ebp, Register word32 esi, Register word32 edi, Register selector es, Stack word32 dwArg00, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 ebpOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn004075D2(byte al, byte ah, word32 ecx, byte dh, byte dl, byte bh, word32 ebp, word32 esi, word32 edi, selector es, word32 dwArg00, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & ebpOut, ptr32 & esiOut, ptr32 & ediOut)
{
*esiOut = esi;
*ebpOut = ebp;
word32 ebx_10 = ebx - edi;
byte bh_11 = SLICE(ebx_10, byte, 8);
word32 edi_29 = edi - ecx - (bh_11 <u 0x13);
word32 eax_6 = DPB(eax, al & ch, 0);
*eaxOut = eax_6;
word32 edx_16 = DPB(edx, dl << cl, 0);
*edxOut = edx_16;
word32 ebx_23 = DPB(ebx_10, bh_11 + 0x13, 8);
word16 bx_25 = DPB(bx, bh_11 + 0x13, 8);
word32 edi_30;
*ediOut = edi_29 << 0x1C;
if (ebx_23 == 4029297085)
{
word32 ebx_81;
*ebxOut = __rcl(DPB(ebx_23, dh & ah, 0), 0x7D, false) - 10667475;
word32 ecx_88 = DPB(355491965, __ror(0x60, 0x15), 8);
*ecxOut = ecx_88;
bool C_92 = (bool) cond(edx_16 - 0x98A0AEA5);
if (edx_16 != 0x98A0AEA5)
{
fn00407A70();
return C_92;
}
else
{
word32 ecx_97;
*ecxOut = ecx_88 - 0x01;
byte cl_99 = (byte) (ecx_88 - 0x01);
if (ecx_88 != 0x01)
{
fn004075BA(cl_99, edx_16, rArg0);
return C_92;
}
else
{
if (OVERFLOW(edx_16 - 0x98A0AEA5))
__syscall(0x04);
word32 eax_101;
*eaxOut = eax_6 ^ 0x80DCD229;
return (bool) dwArg00;
}
}
}
word32 edx_129 = __ror(edx_16, 0x01);
byte dl_130 = (byte) edx_129;
byte dh_131 = SLICE(edx_129, byte, 8);
word16 dx_132 = (word16) edx_129;
word32 ebx_140 = DPB(ebx_23, bx_25 << 0x53, 0);
word16 cx_147 = bx_25 << 0x53 & 48979;
byte cl_149 = (byte) cx_147;
word16 bx_154 = (word16) (ebx_140 - 2802281791);
byte dh_144 = dh_131 & dl_130;
byte bl_162 = __rcr((byte) (ebx_140 - 2802281791), cl_149, (bool) cond(ebx_140 - 2802281791));
word32 edi_165 = DPB(edi_29 << 0x33, bx_154, 0) >>u cl_149;
word32 eax_143 = DPB(eax_6 | 0x603C2F2C, 0x3D, 0);
word32 edx_145 = DPB(edx_129, dh_144, 8);
word16 dx_146 = DPB(dx_132, dh_144, 8);
word32 ecx_150 = DPB(20299603, cx_147, 0);
word32 esp_159 = fp - 0x04;
word32 ebx_163 = DPB(ebx_140 - 2802281791, bl_162, 0);
word16 bx_164 = DPB(bx_154, bl_162, 0);
word16 di_166 = (word16) edi_165;
if (edx_145 != 456539688)
{
word32 eax_283;
word32 ecx_284;
word32 edx_285;
word32 ebx_286;
word32 esi_287;
word32 edi_288;
return fn00407931(eax_143, ecx_150, dx_146, bx_164, ebp, esi - ~0x0B7F, es, out eax_283, out ecx_284, out edx_285, out ebx_286, out esi_287, out edi_288);
}
Mem170[esi + 2920832203:byte] = Mem0[esi + 2920832203:byte] - ~0x19;
do
{
word32 eax_185 = eax_143 & ~0x0FFF;
l0040773E:
if (Mem170[eax_185 + 0x00:word32] == 0x00905A4D)
{
ecx_150 = eax_185;
eax_143 = eax_185 + Mem170[eax_185 + 0x3C:word32];
goto l0040774B;
}
eax_143 = eax_185 - 0x01;
byte al_261 = (byte) eax_143;
byte ah_262 = SLICE(eax_143, byte, 8);
} while (eax_143 != 759522041);
if (eax_143 >= 759522041)
{
word16 cx_271 = DPB(cx_147, 0x5E, 8);
word32 ebx_273 = DPB(ebx_163, Mem170[edx_145 + 0x00:byte], 0);
word32 eax_275;
word32 ecx_276;
word32 edx_277;
word32 ebx_278;
word32 esi_279;
word32 edi_280;
return fn00407783(al_261, ah_262, cx_271, dl_130, ebx_273, ebp, esi - ~0x0B7F, di_166, es, out eax_275, out ecx_276, out edx_277, out ebx_278, out esi_279, out edi_280);
}
l0040774B:
word32 esp_217 = esp_159 - 0x04;
Mem218[esp_217 + 0x00:word32] = Mem170[eax_143 + 0x50:word32];
Mem220[esp_217 - 0x04 + 0x00:word32] = ecx_150;
if (edi_165 != 1846064105)
{
word32 eax_243;
word32 ecx_244;
word32 edx_245;
word32 ebx_246;
word32 ebp_247;
word32 esi_248;
word32 edi_249;
return fn0040788C(eax_143, ecx_150, dl_130, dh_144, bx_164, ebp, edi_165, es, out eax_243, out ecx_244, out edx_245, out ebx_246, out ebp_247, out esi_248, out edi_249);
}
Mem226[esp_217 - 0x08 + 0x00:word32] = ebp;
__syscall(0x23);
Mem230[esp_217 - ~0x2421 + 0x00:word32] = ecx_150;
Mem236[esp_217 - ~0x241D + 0x00:word32] = esp_217 - ~0x2421;
Mem238[esp_217 - ~0x2419 + 0x00:word32] = 0x40;
*ebpOut = esp_217 - 0x08;
ecx_150 = esp_217 - ~0x2421;
cx_147 = (word16) (esp_217 - ~0x2421);
esp_159 = esp_217 - ~0x2419;
eax_185 = 0x00407771;
goto l0040773E;
}
// 00407698: FlagGroup bool fn00407698(Register byte al, Register byte cl, Register byte ch, Register word32 edx, Register byte bl, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 ediOut)
bool fn00407698(byte al, byte cl, byte ch, word32 edx, byte bl, word32 edi, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & ediOut)
{
ptr32 fp;
byte al;
byte ch;
byte bl;
byte cl;
word16 bx;
word32 eax;
word16 cx;
word32 ecx;
word32 edx;
word32 ebx;
ptr32 eaxOut;
ptr32 ecxOut;
ptr32 edxOut;
ptr32 ebxOut;
ptr32 ediOut;
word32 edi;
esp_1 = fp;
al_3 = al | 0xB4;
ch_5 = -ch;
v8_7 = (bl & 0x00) != 0x00;
bl_8 = __rol(bl, 0x1B);
bl_9 = bl_8 & 0xD2;
C_10 = false;
v11_12 = (bl_9 & 0x01 << cl) != 0x00;
bl_13 = __rcr(bl_9, cl, C_10);
bx_15 = DPB(bx, bl_13, 0);
al_16 = al_3 - 0x01;
eax_18 = DPB(eax, al_16, 0);
cl_19 = cl << cl;
cl_20 = cl_19 ^ 0x2F;
cx_22 = DPB(cx, cl_20, 0);
ecx_24 = DPB(ecx, cl_20, 0);
edx_26 = -edx;
dl_27 = (byte) edx_26;
C_28 = edx_26 == 0x00;
bx_29 = bx_15 + cx_22 + (edx_26 == 0x00);
bl_30 = (byte) bx_29;
ebx_32 = DPB(ebx, bx_29, 0);
SCZO_33 = cond(ebx_32 - 0x05A65316);
C_34 = (bool) SCZO_33;
SZO_35 = SCZO_33;
Z_36 = (bool) SCZO_33;
if (ebx_32 != 0x05A65316)
{
C_61 = fn00407C80(eax_18, ecx_24, dl_27, bl_30, out eax_57, out ecx_58, out edx_59, out ebx_60);
SCZO_62 = DPB(SCZO_33, C_61, 0);
return C_61;
}
else
{
C_55 = fn004076BD(al_16, ch_5, cl_20, edx_26, ebx_32, edi, out eax_50, out ecx_51, out edx_52, out ebx_53, out edi_54);
SCZO_56 = DPB(SCZO_33, C_55, 0);
return C_55;
}
}
// 004076BD: FlagGroup bool fn004076BD(Register byte al, Register byte ch, Register byte cl, Register word32 edx, Register word32 ebx, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 ediOut)
bool fn004076BD(byte al, byte ch, byte cl, word32 edx, word32 ebx, word32 edi, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & ediOut)
{
word32 ecx_23 = __rcl(DPB(ecx, ~ch, 8), cl, (bool) cond(ebx >>u 0x0F));
word32 eax_10;
*eaxOut = 652050454;
byte ch_24 = SLICE(ecx_23, byte, 8);
word32 edx_28;
*edxOut = edx - 0x01;
byte dh_29 = SLICE(edx - 0x01, byte, 8);
byte dl_30 = (byte) (edx - 0x01);
word32 edi_33;
*ediOut = edi >>u 22;
word32 ecx_36 = DPB(ecx_23, ch_24 & dh_29, 8);
byte cl_41 = (byte) (ecx_36 >> 0x04);
byte cl_43 = __ror(cl_41, 0x1A);
byte bh_46 = __rcr(199, cl_43, (cl_41 & 0x00) != 0x00);
word32 ebx_47 = DPB(3484665775, bh_46, 8);
word32 ecx_50 = DPB(ecx_36 >> 0x04, cl_43 + SLICE(ecx_36 >> 0x04, byte, 8) + ((0x01 << cl_43 & 199) != 0x00), 0);
*ecxOut = ecx_50;
if (edi >>u 22 != 2804291970)
{
word32 ecx_98 = ecx_50 + 1189935831 | ~0x3157706C;
word32 ebx_95 = __ror(DPB(ebx_47, ~0x51 - bh_46, 0), 0x08);
*ebxOut = ebx_95;
word32 ecx_102 = DPB(ecx_98, (byte) ecx_98 >> 0x08, 0);
*ecxOut = ecx_102;
byte bh_96 = SLICE(ebx_95, byte, 8);
bool C_104 = (bool) cond(ecx_102 - 171682146);
if (ecx_102 != 171682146)
{
fn00407CF5();
return C_104;
}
else
{
__outb(0x3A, 22);
word32 ebx_108;
*ebxOut = DPB(ebx_95, bh_96 + Mem0[(ebx_95 - 0x80) + 0x00:byte] + (ecx_102 <u 171682146), 8);
word32 eax_110;
return fn004078D7(22, out eax_110);
}
}
else
{
word32 edi_74;
*ediOut = (edi >>u 22) + 0x04;
word32 ebx_76;
*ebxOut = DPB(ebx_47, bh_46 ^ Mem0[ecx_50 + 0x31:byte], 8);
word32 eax_77;
*eaxOut = 2784490945;
word32 edx_85;
*edxOut = DPB(edx - 0x01, dl_30 + 0x5E, 0);
return (bool) cond(dl_30 + 0x5E);
}
}
// 00407783: FlagGroup bool fn00407783(Register byte al, Register byte ah, Register word16 cx, Register byte dl, Register word32 ebx, Register word32 ebp, Register word32 esi, Register word16 di, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407783(byte al, byte ah, word16 cx, byte dl, word32 ebx, word32 ebp, word32 esi, word16 di, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
ptr32 fp;
byte ch;
word16 di;
word16 cx;
bool C;
word32 edi;
byte al;
word32 eax;
word32 esi;
byte cl;
word32 ecx;
byte dl;
word32 edx;
ptr32 eaxOut;
ptr32 ecxOut;
ptr32 edxOut;
ptr32 ebxOut;
ptr32 esiOut;
ptr32 ediOut;
byte ah;
word32 ebx;
word16 bx;
word32 ebp;
selector es;
esp_1 = fp;
__cli();
dh_3 = ch;
di_7 = di - cx - C;
edi_9 = DPB(edi, di_7, 0);
al_11 = al >>u 0x01;
eax_13 = DPB(eax, al_11, 0);
edi_14 = edi_9 & 0x81B1D007;
di_15 = (word16) edi_14;
esi_17 = esi + ~0x0B7F;
ch_18 = ch << 0x09;
cl_20 = cl & 0x1B;
cx_21 = DPB(cx, cl_20, 0);
ecx_23 = DPB(ecx, cl_20, 0);
di_24 = di_15 << cl_20;
edi_25 = DPB(edi_14, di_24, 0);
SCZO_26 = cond(di_24);
C_27 = (bool) SCZO_26;
v14_29 = (dl & 0x00) != 0x00;
dl_30 = __rcl(dl, 0x11, C_27);
edx_32 = DPB(edx, dl_30, 0);
SCZO_33 = cond(esi_17 - 3967653687);
C_34 = (bool) SCZO_33;
SZO_35 = SCZO_33;
Z_36 = (bool) SCZO_33;
if (esi_17 != 3967653687)
{
C_70 = fn004078FD(eax_13, cl_20, dl_30, bx, ebp, esi_17, di_24, es, out eax_64, out ecx_65, out edx_66, out ebx_67, out esi_68, out edi_69);
SCZO_71 = DPB(SCZO_33, C_70, 0);
return C_70;
}
else
{
C_59 = fn004077B0(al_11, ah, ecx_23, edx_32, ebx, edi_25, out eax_53, out ecx_54, out edx_55, out ebx_56, out esi_57, out edi_58);
SCZO_60 = DPB(SCZO_33, C_59, 0);
return C_59;
}
}
// 004077B0: FlagGroup bool fn004077B0(Register byte al, Register byte ah, Register word32 ecx, Register word32 edx, Register word32 ebx, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn004077B0(byte al, byte ah, word32 ecx, word32 edx, word32 ebx, word32 edi, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
*edxOut = edx;
*ebxOut = ebx;
*ediOut = edi;
__arpl(Mem0[edx + 0x00:word16], bx, &Mem0[edx + 0x00:word16]);
word16 cx_17 = DPB(cx, SLICE(__rol(ecx, 0x12), byte, 8) + 0x01, 8) | di;
word32 esi_2;
*esiOut = 253400207;
byte cl_18 = (byte) cx_17;
byte ch_19 = SLICE(cx_17, byte, 8);
if (ebx != 0xBEB22032)
{
word32 eax_51;
word32 ecx_52;
return fn00407CC1(al, ah, cl_18, ch_19, out eax_51, out ecx_52);
}
else
{
word32 eax_42;
word32 ecx_43;
word32 edx_44;
word32 ebx_45;
word32 esi_46;
word32 edi_47;
return fn004077CE(al, cx_17, dl, dh, ebx, 253400207, edi, out eax_42, out ecx_43, out edx_44, out ebx_45, out esi_46, out edi_47);
}
}
// 004077CE: FlagGroup bool fn004077CE(Register byte al, Register word16 cx, Register byte dl, Register byte dh, Register word32 ebx, Register word32 esi, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn004077CE(byte al, word16 cx, byte dl, byte dh, word32 ebx, word32 esi, word32 edi, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
byte al_7 = __rol(al, cl);
word32 edi_11 = -edi;
word16 cx_30 = cx + 0x01 + (word16) edi_11;
word32 ebx_17 = ebx + 112215167 + (edi_11 == 0x00);
ui32 cl_cx_35 = SEQ(cl, cx_30) + DPB(ch_di, cx_30, 16);
word32 esi_15;
*esiOut = esi - 0x01;
byte bl_18 = (byte) ebx_17;
word32 edx_25 = DPB(edx, dh + dl + (ebx_17 <u 0x00), 8);
byte cl_36 = (byte) cl_cx_35;
byte ch_37 = SLICE(cl_cx_35, byte, 8);
word32 eax_41;
word32 ecx_42;
word32 edx_43;
word32 ebx_44;
word32 edi_45;
return fn00407698(al_7 >> 0x09, cl_36, ch_37, edx_25, bl_18, edi_11, out eax_41, out ecx_42, out edx_43, out ebx_44, out edi_45);
}
// 00407837: FlagGroup bool fn00407837(Register word16 ax, Register byte cl, Register byte ch, Register byte dl, Register byte dh, Register word16 bx, Register word32 ebp, Register word32 esi, Register word32 edi, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 ebpOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407837(word16 ax, byte cl, byte ch, byte dl, byte dh, word16 bx, word32 ebp, word32 esi, word32 edi, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & ebpOut, ptr32 & esiOut, ptr32 & ediOut)
{
word16 ax_8 = __ror(ax, cl);
byte ah_11 = SLICE(ax_8, byte, 8);
byte al_12 = (byte) ax_8;
word32 ecx_20 = DPB(ecx, ch ^ ah_11, 8);
byte bh_26 = SLICE(__rcl((word16) (ebx & 2161462229), cl, false), byte, 8);
word32 eax_34;
word32 ecx_35;
word32 edx_36;
word32 ebx_37;
word32 ebp_38;
word32 esi_39;
word32 edi_40;
return fn004075D2(al_12, ah_11, ecx_20, dh, dl >>u 0x11, bh_26, ebp, esi, edi, es, dwArg00, out eax_34, out ecx_35, out edx_36, out ebx_37, out ebp_38, out esi_39, out edi_40);
}
// 00407856: FlagGroup bool fn00407856(Register byte al, Register word16 cx, Register byte dl, Register byte dh, Register word16 bx, Register word32 ebp, Register word16 si, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 ebpOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407856(byte al, word16 cx, byte dl, byte dh, word16 bx, word32 ebp, word16 si, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & ebpOut, ptr32 & esiOut, ptr32 & ediOut)
{
ptr32 fp;
byte al;
word32 eax;
byte dl;
byte cl;
word32 edx;
word16 bx;
word16 cx;
word32 ebx;
word16 si;
word16 ax;
word32 ecx;
<type-error> Mem0;
byte dh;
word32 ebp;
selector es;
ptr32 eaxOut;
ptr32 ecxOut;
ptr32 edxOut;
ptr32 ebxOut;
ptr32 ebpOut;
ptr32 esiOut;
ptr32 ediOut;
esp_1 = fp;
al_3 = al + 0x01;
eax_5 = DPB(eax, al_3, 0);
dl_8 = dl - cl;
edx_10 = DPB(edx, dl_8, 0);
bx_13 = bx | cx;
ebx_15 = DPB(ebx, bx_13, 0);
C_16 = false;
eax_17 = eax_5 + 2073977646 + C_16;
al_18 = (byte) eax_17;
si_20 = si << cl;
v14_21 = (al_18 & 0x01 << cl) != 0x00;
al_22 = __ror(al_18, cl);
eax_23 = DPB(eax_17, al_22, 0);
ax_25 = DPB(ax, al_22, 0);
C_26 = v14_21;
edi_27 = edx_10;
ebx_28 = ebx_15 + 639297340 + ((al_18 & 0x01 << cl) != 0x00);
bh_29 = SLICE(ebx_28, byte, 8);
bx_30 = (word16) ebx_28;
bl_31 = (byte) ebx_28;
cl_32 = cl << 0x05;
cx_33 = DPB(cx, cl_32, 0);
ecx_35 = DPB(ecx, cl_32, 0);
SCZO_36 = cond(ecx_35 - 2514536642);
Z_37 = (bool) SCZO_36;
if (ecx_35 != 2514536642)
{
bl_73 = bl_31 + 252;
SCZO_74 = cond(bl_73);
}
else
{
v20_39 = Mem0[edi_27 + 0x00:word32] >>u cl_32;
Mem40[edi_27 + 0x00:word32] = v20_39;
eax_41 = eax_23 + 0x808D7E79;
al_42 = (byte) eax_41;
ax_43 = (word16) eax_41;
SCZO_44 = cond(eax_41);
C_55 = fn0040788C(eax_41, ecx_35, dl_8, dh, bx_30, ebp, edi_27, es, out eax_48, out ecx_49, out edx_50, out ebx_51, out ebp_52, out esi_53, out edi_54);
SCZO_56 = DPB(SCZO_44, C_55, 0);
return C_55;
}
}
// 0040788C: FlagGroup bool fn0040788C(Register word32 eax, Register word32 ecx, Register byte dl, Register byte dh, Register word16 bx, Register word32 ebp, Register word32 edi, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 ebpOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn0040788C(word32 eax, word32 ecx, byte dl, byte dh, word16 bx, word32 ebp, word32 edi, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & ebpOut, ptr32 & esiOut, ptr32 & ediOut)
{
}
// 004078D7: FlagGroup bool fn004078D7(Register byte al, Register out ptr32 eaxOut)
bool fn004078D7(byte al, ptr32 & eaxOut)
{
}
// 004078FD: FlagGroup bool fn004078FD(Register word32 eax, Register byte cl, Register byte dl, Register word16 bx, Register word32 ebp, Register word32 esi, Register word16 di, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn004078FD(word32 eax, byte cl, byte dl, word16 bx, word32 ebp, word32 esi, word16 di, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
word16 di_6 = __rcl(di, cl, C);
word32 eax_16;
word32 ecx_17;
word32 edx_18;
word32 ebx_19;
word32 esi_20;
word32 edi_21;
return fn00407900(eax, cl, dl, bx, ebp, esi, di_6, es, out eax_16, out ecx_17, out edx_18, out ebx_19, out esi_20, out edi_21);
}
// 004078FE: FlagGroup bool fn004078FE(Register word32 eax, Register byte cl, Register byte dl, Register word16 bx, Register word32 ebp, Register word32 esi, Register word32 edi, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn004078FE(word32 eax, byte cl, byte dl, word16 bx, word32 ebp, word32 esi, word32 edi, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
word16 di_7 = (word16) __rcl(edi, cl, C);
word32 eax_15;
word32 ecx_16;
word32 edx_17;
word32 ebx_18;
word32 esi_19;
word32 edi_20;
return fn00407900(eax, cl, dl, bx, ebp, esi, di_7, es, out eax_15, out ecx_16, out edx_17, out ebx_18, out esi_19, out edi_20);
}
// 00407900: FlagGroup bool fn00407900(Register word32 eax, Register byte cl, Register byte dl, Register word16 bx, Register word32 ebp, Register word32 esi, Register word16 di, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407900(word32 eax, byte cl, byte dl, word16 bx, word32 ebp, word32 esi, word16 di, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
ptr32 fp;
word32 eax;
word32 ecx;
byte cl;
word16 bx;
word32 ebx;
word16 di;
byte dl;
word16 dx;
word32 edx;
word32 esi;
ptr32 eaxOut;
ptr32 ecxOut;
ptr32 edxOut;
ptr32 ebxOut;
ptr32 esiOut;
ptr32 ediOut;
word32 ebp;
selector es;
real64 rArg0;
word32 dwArg00;
esp_1 = fp;
eax_3 = eax - 1267989644;
SCZO_4 = cond(eax_3);
C_5 = (bool) SCZO_4;
ch_6 = 0x59;
ecx_8 = DPB(ecx, ch_6, 8);
v7_10 = (ecx_8 & 0x01 << 0x20 - cl) != 0x00;
ecx_11 = __rcl(ecx_8, cl, C_5);
ch_12 = SLICE(ecx_11, byte, 8);
cl_13 = (byte) ecx_11;
cx_14 = (word16) ecx_11;
eax_15 = eax_3 - 3816440331;
ax_16 = (word16) eax_15;
bx_18 = -bx;
ebx_20 = DPB(ebx, bx_18, 0);
ax_22 = ax_16 | di;
dl_24 = dl + 0x25;
dx_26 = DPB(dx, dl_24, 0);
SCZO_27 = cond(dl_24);
C_28 = (bool) SCZO_27;
dx_29 = dx_26 + cx_14 + (dl_24 <u 0x00);
dl_30 = (byte) dx_29;
edx_32 = DPB(edx, dx_29, 0);
dx_dl_33 = dx_29;
ax_34 = -ax_22;
eax_35 = DPB(eax_15, ax_34, 0);
SCZO_37 = cond(esi - 3480418694);
Z_38 = (bool) SCZO_37;
if (esi != 3480418694)
{
C_73 = fn00407BD2(ax_34, cx_14, bx_18, ebp, esi, di, es, dwArg00, rArg0, out eax_66, out ecx_67, out edx_68, out ebx_69, out esi_70, out edi_71, out rArg0_72);
SCZO_74 = DPB(SCZO_37, C_73, 0);
return C_73;
}
else
{
C_62 = fn0040792B(ecx_11, dx_29, bx_18, ebp, esi, es, out eax_56, out ecx_57, out edx_58, out ebx_59, out esi_60, out edi_61);
SCZO_63 = DPB(SCZO_37, C_62, 0);
return C_62;
}
}
// 0040792B: FlagGroup bool fn0040792B(Register word32 ecx, Register word16 dx, Register word16 bx, Register word32 ebp, Register word32 esi, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn0040792B(word32 ecx, word16 dx, word16 bx, word32 ebp, word32 esi, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
word16 ax_6 = DPB(ax, Mem0[esi + 0x00:byte], 0);
Mem10[v3 - 0x04 + 0x00:word32] = ecx;
__lock();
word16 ax_11 = __aad(ax_6);
__outb(dx, (byte) ax_11);
word32 eax_14 = DPB(eax, ax_11, 0);
word32 eax_20;
word32 ecx_21;
word32 edx_22;
word32 ebx_23;
word32 esi_24;
word32 edi_25;
return fn00407931(eax_14, ecx, dx, bx, ebp, esi + 0x02, es, out eax_20, out ecx_21, out edx_22, out ebx_23, out esi_24, out edi_25);
}
// 00407931: FlagGroup bool fn00407931(Register word32 eax, Register word32 ecx, Register word16 dx, Register word16 bx, Register word32 ebp, Register word32 esi, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407931(word32 eax, word32 ecx, word16 dx, word16 bx, word32 ebp, word32 esi, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
word16 cx_19 = (word16) __ror(ecx, cl);
word16 bx_28 = -bx;
byte al_12 = (byte) (eax << 0x05);
byte ah_13 = SLICE(eax << 0x05, byte, 8);
byte dl_22 = (byte) __rol(DPB(edx, dx >>u cl, 0) >>u 0x0A, 0x01);
word32 ebx_30 = DPB(ebx, bx_28, 0);
byte bh_31 = SLICE(bx_28, byte, 8);
if (eax << 0x05 != 259932953)
{
word32 ebx_38 = DPB(ebx_30, bh_31 - (dl_22 >> 0x03) - (eax << 0x05 <u 259932953), 8);
word32 eax_46;
word32 ecx_47;
word32 edx_48;
word32 ebx_49;
word32 esi_50;
word32 edi_51;
return fn00407783(al_12, ah_13, cx_19, dl_22 >> 0x03, ebx_38, ebp, esi, 15318, es, out eax_46, out ecx_47, out edx_48, out ebx_49, out esi_50, out edi_51);
}
else
__hlt();
}
// 00407A40: FlagGroup bool fn00407A40(Register word16 ax, Register byte cl, Register word32 edx, Register byte bl, Register word32 esi, Register word32 edi, Register selector es, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 ediOut)
bool fn00407A40(word16 ax, byte cl, word32 edx, byte bl, word32 esi, word32 edi, selector es, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & ediOut)
{
*ediOut = edi;
word32 ecx_19 = DPB(ecx, cl << 0x1A, 0) & edi;
*ecxOut = ecx_19;
byte cl_20 = (byte) ecx_19;
word32 eax_6 = DPB(eax, ax >>u cl, 0);
byte bl_28 = 0x20 >>u cl_20;
word32 edx_12;
*edxOut = edx ^ 1740494801;
byte dh_13 = SLICE(edx ^ 1740494801, byte, 8);
word16 cx_22 = (word16) ecx_19;
byte al_26 = (byte) (eax_6 - 0xA3D42ED0);
byte ah_27 = SLICE(eax_6 - 0xA3D42ED0, byte, 8);
word32 ebx_29;
*ebxOut = DPB(0x52810120, bl_28, 0);
bool C_35 = (bool) cond(eax_6 - 0x23277E83);
if (eax_6 != 0x23277E83)
{
__rol(cl_20, 0x10);
word32 edi_72 = __rcl(~edi, 0x07, (cl_20 & 0x00) != 0x00);
*ediOut = edi_72;
word32 ecx_74 = __ror(DPB(ecx_19, ~0x34, 8), 0x0D);
byte ch_76 = SLICE(ecx_74, byte, 8);
byte cl_75 = (byte) ecx_74;
word32 ecx_79 = DPB(ecx_74, ch_76 - 0x8A, 8);
word16 cx_80 = DPB(cx_22, ch_76 - 0x8A, 8);
if (ecx_79 != 3646762296)
{
word32 eax_93;
word32 ecx_94;
word32 ebx_95;
return fn00407CA8(al_26, ah_27, cx_80, dh_13, bl_28, 0x01, si, out eax_93, out ecx_94, out ebx_95);
}
else
{
Mem83[es:esi + 3033039015:word32] = ecx_79;
word32 eax_85;
word32 ecx_86;
word32 edx_87;
word32 ebx_88;
word32 edi_89;
return fn00407698(al_26, cl_75, ch_76 - 0x8A, edx ^ 1740494801, bl_28, edi_72, out eax_85, out ecx_86, out edx_87, out ebx_88, out edi_89);
}
}
else
{
word32 eax_59;
*eaxOut = Mem0[esi + 0x00:word32];
fn00407A70();
return C_35;
}
}
// 00407A70: void fn00407A70()
void fn00407A70()
{
}
// 00407AB7: FlagGroup bool fn00407AB7(Register byte al, Register byte ah, Register byte cl, Register word32 edx, Register word32 ebx, Register word16 di, Stack word32 dwArg00, FpuStack real64 rArg0, FpuStack real64 rArg6, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 ebxOut, Register out ptr32 ediOut, FpuStack out ptr32 rArg0Out)
bool fn00407AB7(byte al, byte ah, byte cl, word32 edx, word32 ebx, word16 di, word32 dwArg00, real64 rArg0, real64 rArg6, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & ebxOut, ptr32 & ediOut, ptr32 & rArg0Out)
{
fn00407AB7_entry:
byte cl_7 = -cl
word32 edi_15
*ediOut = -DPB(edi, di << cl, 0)
word32 eax_25 = DPB(eax, __rol(DPB(ax, (al & dh) - 0x01, 0), cl_7), 0)
*eaxOut = eax_25
word16 bx_30 = (word16) (ebx + 95319657)
word16 bx_42 = DPB(bx_30, __rcl(SLICE(~DPB(ebx + 95319657 << cl_7, 0x0D, 0), byte, 8), 0x08, false), 8)
word32 ecx_44 = DPB(ecx, cl_7 ^ 0x30, 0)
*ecxOut = ecx_44
branch eax_25 != 1741511763 l00407CE8_thunk_fn00407C21
goto l00407CEE
l00407AB7:
l00407AB7:
l00407CD0:
l00407CE8_thunk_fn00407C21:
word32 ebx_60
return fn00407C21(edx, bx_42, out ebx_60)
l00407CEE:
branch DPB(ecx_44, 0xC6, 8) != 0x01 l00407C81
fn00407AB7_exit:
}
// 00407B47: FlagGroup bool fn00407B47(Register byte al, Register byte cl, Register word32 edx, Register byte bl, Register byte bh, Register word16 si, Register word16 di, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 ebxOut, Register out ptr32 ediOut)
bool fn00407B47(byte al, byte cl, word32 edx, byte bl, byte bh, word16 si, word16 di, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & ebxOut, ptr32 & ediOut)
{
word32 eax_16 = DPB(eax, (byte) (ax ^ di) - bl, 0) | esi;
word32 eax_32 = -DPB(eax_16, SLICE(eax_16, byte, 8) - 0x06 ^ 118, 8);
word32 ebx_27 = DPB(ebx, DPB(bx, -__rcr(bh, cl, false), 8) - 0x01, 0);
byte al_34 = (byte) eax_32;
byte ah_35 = SLICE(eax_32, byte, 8);
word32 eax_42;
word32 ecx_43;
word32 ebx_44;
word32 edi_45;
real64 rArg0_46;
return fn00407AB7(al_34, ah_35, cl, edx, ebx_27 << 0x15, di, dwLoc04, rArg0, rArg6, out eax_42, out ecx_43, out ebx_44, out edi_45, out rArg0_46);
}
// 00407B90: FlagGroup byte fn00407B90(Register word16 ax, Register byte ch, Register word32 edx, Register byte bl, Register byte bh, Register word32 esi, Register word32 edi, Stack word32 dwArg00, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 ebxOut, Register out ptr32 ediOut)
byte fn00407B90(word16 ax, byte ch, word32 edx, byte bl, byte bh, word32 esi, word32 edi, word32 dwArg00, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & ebxOut, ptr32 & ediOut)
{
byte bh_5 = bh + bl + C;
byte cl_12 = Mem0[esi + 0x00:byte];
word16 ax_16 = ax - DPB(bx, bh_5, 8);
word32 edi_22 = __rcr(edi, cl_12, (bool) cond(ax_16));
byte al_17 = (byte) ax_16;
word32 ebx_7;
*ebxOut = DPB(ebx, bh_5, 8);
word32 ecx_14;
*ecxOut = DPB(ecx, cl_12, 0);
word16 di_23 = (word16) edi_22;
word32 eax_27 = DPB(eax, al_17 << 0x14, 0);
byte SCZO_29 = cond(edx - 0x5E0EBF72);
if (edx != 0x5E0EBF72)
{
word32 eax_73;
word32 ecx_74;
word32 ebx_75;
word32 edi_76;
return DPB(SCZO_29, fn00407B47(al_17 << 0x14, cl_12, edx, bl, bh_5, si, di_23, out eax_73, out ecx_74, out ebx_75, out edi_76), 0);
}
else
{
Mem61[edi_22 + 0x01:byte] = Mem0[edi_22 + 0x01:byte] | ch;
word32 edi_54;
*ediOut = edi_22 + 0x01;
word32 eax_63;
*eaxOut = eax_27 ^ 2153019942;
byte CDP_71 = DPB(SCZO_29, false, 0);
fn00407BB6();
return CDP_71;
}
}
// 00407BB6: void fn00407BB6()
void fn00407BB6()
{
}
// 00407BCA: void fn00407BCA()
void fn00407BCA()
{
__sti();
}
// 00407BD2: FlagGroup bool fn00407BD2(Register word16 ax, Register word16 cx, Register word16 bx, Register word32 ebp, Register word32 esi, Register word16 di, Register selector es, Stack word32 dwArg00, FpuStack real64 rArg0, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut, FpuStack out ptr32 rArg0Out)
bool fn00407BD2(word16 ax, word16 cx, word16 bx, word32 ebp, word32 esi, word16 di, selector es, word32 dwArg00, real64 rArg0, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut, ptr32 & rArg0Out)
{
*esiOut = esi;
word32 ecx_10 = -ecx;
byte cl_11 = (byte) ecx_10;
word16 ax_7 = __rol(ax, cl);
word16 bx_14 = bx << cl_11;
byte al_8 = (byte) ax_7;
byte cl_24 = cl_11 << cl_11;
byte bl_17 = (byte) bx_14;
word16 ax_21 = DPB(ax_7, al_8 ^ 0x1C, 0);
word32 ecx_25 = DPB(ecx_10, cl_24, 0);
*ecxOut = ecx_25;
word32 edi_31 = DPB(edi, di << cl_24, 0);
if (edi_31 != 3287611774)
{
word32 eax_73;
word32 ecx_74;
word32 edx_75;
word32 ebx_76;
word32 edi_77;
return fn00407A40(ax_21, cl_24, 0x67BDDC3B, bl_17, esi, edi_31, es, out eax_73, out ecx_74, out edx_75, out ebx_76, out edi_77);
}
else
{
__outb(~0x23C4, al_8 ^ 0x1C);
Mem59[ecx_25 - 0x27 + 0x00:word32] = Mem0[ecx_25 - 0x27 + 0x00:word32] & ecx_25;
Mem63[ebp + 0x66:real80] = (real80) rArg0;
word32 edx_54;
*edxOut = dwArg00;
word16 dx_55 = (word16) dwArg00;
word32 eax_66;
word32 ebx_67;
word32 esi_68;
word32 edi_69;
return fn00407C00(ax_21, cl_24, dx_55, bx_14, esi + 0x01, edi_31, dwArg04, out eax_66, out ebx_67, out esi_68, out edi_69);
}
}
// 00407BFF: FlagGroup bool fn00407BFF(Register word16 ax, Register byte cl, Register word16 dx, Register word16 bx, Register word32 esi, Register word32 edi, Register out ptr32 eaxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407BFF(word16 ax, byte cl, word16 dx, word16 bx, word32 esi, word32 edi, ptr32 & eaxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
word32 eax_14;
word32 ebx_15;
word32 esi_16;
word32 edi_17;
return fn00407C00(ax + 0x01, cl, dx, bx, esi, edi, dwArg00, out eax_14, out ebx_15, out esi_16, out edi_17);
}
// 00407C00: FlagGroup bool fn00407C00(Register word16 ax, Register byte cl, Register word16 dx, Register word16 bx, Register word32 esi, Register word32 edi, Stack word32 dwArg00, Register out ptr32 eaxOut, Register out ptr32 ebxOut, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407C00(word16 ax, byte cl, word16 dx, word16 bx, word32 esi, word32 edi, word32 dwArg00, ptr32 & eaxOut, ptr32 & ebxOut, ptr32 & esiOut, ptr32 & ediOut)
{
ptr32 fp;
word32 eax;
byte cl;
word16 bx;
word16 dx;
word32 ebx;
byte dh;
word32 esi;
ptr32 eaxOut;
ptr32 ebxOut;
ptr32 esiOut;
ptr32 ediOut;
word32 edi;
word32 dwArg00;
esp_1 = fp;
eax_3 = eax + 0x01;
ah_4 = SLICE(eax_3, byte, 8);
v6_6 = (ah_4 & 0x01 << 0x08 - cl) != 0x00;
ah_7 = __rol(ah_4, cl);
C_8 = v6_6;
bx_11 = bx + dx + ((ah_4 & 0x01 << 0x08 - cl) != 0x00);
bl_12 = (byte) bx_11;
SCZO_13 = cond(bx_11);
C_14 = (bool) SCZO_13;
ah_15 = ah_7 + 0x02 + (bx_11 <u 0x00);
bl_16 = bl_12 & 118;
bx_17 = DPB(bx_11, bl_16, 0);
ebx_19 = DPB(ebx, bl_16, 0);
ah_21 = ah_15 + dh;
eax_22 = DPB(eax_3, ah_21, 8);
eax_23 = -eax_22;
ah_24 = SLICE(eax_23, byte, 8);
ax_25 = (word16) eax_23;
SCZO_27 = cond(esi - 4157013144);
C_28 = (bool) SCZO_27;
SZO_29 = SCZO_27;
Z_30 = (bool) SCZO_27;
if (esi != 4157013144)
{
SCZO_48 = dwArg00;
C_49 = (bool) SCZO_48;
SZO_50 = SCZO_48;
Z_51 = (bool) SCZO_48;
esp_52 = fp + 0x04;
return C_49;
}
else
{
C_45 = fn00407C1C(ebx_19, esi, edi, out esi_43, out edi_44);
SCZO_46 = DPB(SCZO_27, C_45, 0);
return C_45;
}
}
// 00407C1C: FlagGroup bool fn00407C1C(Register word32 ebx, Register word32 esi, Register word32 edi, Register out ptr32 esiOut, Register out ptr32 ediOut)
bool fn00407C1C(word32 ebx, word32 esi, word32 edi, ptr32 & esiOut, ptr32 & ediOut)
{
Mem5[edi + 0x00:byte] = Mem0[esi + 0x00:byte];
word32 esi_7;
*esiOut = esi + 0x01;
word32 edi_8;
*ediOut = edi + 0x01;
if (C)
{
fn00407BCA();
return C;
}
else
{
word32 esi_16;
*esiOut = esi + 0x01 | 601618278;
fn00407C25(ebx, rArg0);
return false;
}
}
// 00407C21: FlagGroup bool fn00407C21(Register word32 edx, Register word16 bx, Register out ptr32 ebxOut)
bool fn00407C21(word32 edx, word16 bx, ptr32 & ebxOut)
{
ptr32 fp;
word16 bx;
word32 ebx;
word32 edx;
byte SCZO;
real64 rArg0;
word32 eax;
word32 esi;
word32 edi;
ptr32 ebxOut;
esp_1 = fp;
bx_3 = -bx;
ebx_5 = DPB(ebx, bx_3, 0);
ebx_7 = ebx_5 & edx;
bx_8 = (word16) ebx_7;
bh_9 = SLICE(ebx_7, byte, 8);
bl_10 = (byte) ebx_7;
SZO_11 = cond(ebx_7);
Z_12 = (bool) SZO_11;
C_13 = false;
SCZO_15 = DPB(SCZO, C_13, 0);
rArg0_17 = fn00407C25(ebx_7, rArg0);
return C_13;
}
// 00407C25: FpuStack real64 fn00407C25(Register word32 ebx, FpuStack real64 rArg0)
real64 fn00407C25(word32 ebx, real64 rArg0)
{
}
// 00407C80: FlagGroup bool fn00407C80(Register word32 eax, Register word32 ecx, Register byte dl, Register byte bl, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut)
bool fn00407C80(word32 eax, word32 ecx, byte dl, byte bl, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut)
{
word32 ebx_7 = DPB(ebx, __rcl(bl, 0x10, C), 0);
word32 eax_12;
word32 ecx_13;
word32 edx_14;
word32 ebx_15;
return fn00407C83(eax, ecx, dl, ebx_7, out eax_12, out ecx_13, out edx_14, out ebx_15);
}
// 00407C83: FlagGroup bool fn00407C83(Register word32 eax, Register word32 ecx, Register byte dl, Register word32 ebx, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 edxOut, Register out ptr32 ebxOut)
bool fn00407C83(word32 eax, word32 ecx, byte dl, word32 ebx, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & edxOut, ptr32 & ebxOut)
{
esp = fp;
v8 = (ebx & 0x40000000) != 0x00;
ebx = __rol(ebx, 0x02);
v10 = (eax & 0x00010000) != 0x00;
eax = __ror(eax, 0x10);
C = v10;
ecx = ecx + ~0x41A48CE9 + C;
ch = SLICE(ecx, byte, 8);
SCZO = cond(ebx - 244419195);
SZO = SCZO;
Z = (bool) SCZO;
C = (bool) SCZO;
if (Test(NE,Z))
{
ah = ch;
ch = ch + ~0x51;
SCZO = cond(ch);
dl = dl + 0x01;
dl_ch = dl_ch + 23982;
SCZO = cond(dl_ch);
return C;
}
else
{
fn00407CA3();
return C;
}
}
// 00407CA3: void fn00407CA3()
void fn00407CA3()
{
}
// 00407CA8: FlagGroup bool fn00407CA8(Register byte al, Register byte ah, Register word16 cx, Register byte dh, Register byte bl, Register byte bh, Register word16 si, Register out ptr32 eaxOut, Register out ptr32 ecxOut, Register out ptr32 ebxOut)
bool fn00407CA8(byte al, byte ah, word16 cx, byte dh, byte bl, byte bh, word16 si, ptr32 & eaxOut, ptr32 & ecxOut, ptr32 & ebxOut)
{
word32 ecx_4 = ecx - esi;
byte cl_6 = (byte) ecx_4;
__rcl(bl, cl_6, false);
byte ch_9 = SLICE(ecx_4, byte, 8) + dh;
word32 ebx_26;
*ebxOut = DPB(ebx, bh + 0x01, 8) + 2311321706 << 0x04;
word32 eax_31;
word32 ecx_32;
return fn00407CC1(al >> 0x13, ah, cl_6, ch_9, out eax_31, out ecx_32);
}
// 00407CC1: FlagGroup bool fn00407CC1(Register byte al, Register byte ah, Register byte cl, Register byte ch, Register out ptr32 eaxOut, Register out ptr32 ecxOut)
bool fn00407CC1(byte al, byte ah, byte cl, byte ch, ptr32 & eaxOut, ptr32 & ecxOut)
{
ptr32 fp;
byte ah;
word32 eax;
byte ch;
word32 ecx;
byte al;
byte SCZO;
word32 edx;
word32 ebx;
word32 esi;
word32 edi;
ptr32 eaxOut;
ptr32 ecxOut;
esp_1 = fp;
ah_3 = ah & ~0x28;
eax_5 = DPB(eax, ah_3, 8);
SZO_6 = cond(ah_3);
C_7 = false;
ch_9 = ch ^ 0x0C;
ecx_11 = DPB(ecx, ch_9, 8);
SZO_12 = cond(ch_9);
C_13 = false;
C_16 = fn004078D7(al, out eax_15);
SCZO_18 = DPB(SCZO, C_16, 0);
return C_16;
}
// 00407CF5: void fn00407CF5()
void fn00407CF5()
{
esp = fp;
ecx = ebx;
}
| [
"i-git-stone@rf.risimo.net"
] | i-git-stone@rf.risimo.net |
c6864ae13f0b5026d0a332c78a3690467038b307 | 2d43bfc19fb454ab6d78b4984a265df9b50fc9d8 | /ch12/1216.c | fc0cced401c5ae759bcbca2f169cbe34b33c23fa | [] | no_license | fabrizzio-gz/csapp_solutions | 6ef66724d79db547cf9364078ff752ca106590aa | 7edb301e67fc78a87ccb8dcd906d6570a031430c | refs/heads/master | 2023-07-30T11:51:01.899640 | 2021-09-21T15:24:49 | 2021-09-21T15:24:49 | 391,474,008 | 2 | 0 | null | null | null | null | UTF-8 | C | false | false | 728 | c | #include "csapp.h"
#define MAX_THREAD 1024
void *thread(void *vargp);
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: ./main <num_threads>\n");
exit(0);
}
int n = atoi(argv[1]);
if ((!n) || (n > MAX_THREAD)) {
fprintf(stderr, "Invalid number of threads: %s\n", argv[1]);
exit(0);
}
pthread_t tid[n];
for (int i = 0; i < n; i++)
Pthread_create(&tid[i], NULL, thread, NULL);
for (int i = 0; i < n; i++)
Pthread_join(tid[i], NULL);
exit(0);
}
void *thread(void *vargp)
{
printf("Hello, world!\n");
return NULL;
}
| [
"fabrizzio.gz@gmail.com"
] | fabrizzio.gz@gmail.com |
520a374941a766c4627a533bb30d55ebe776dee9 | 66bc2b85e52c6d124a6add7c7a74e4f7313404c3 | /graph/unweighted_digraph/unweighted_digraph.h | 01d0f6eaaced821f5cab7964df0cd1768bc0aab0 | [
"MIT"
] | permissive | Talendar/data_structures_c | dcca3f6f39b658d6011982ad2a7de838e264a4d8 | f470573d898a49baee33da648ccf4ef30f35275a | refs/heads/master | 2020-08-10T11:14:52.241641 | 2020-07-02T03:11:55 | 2020-07-02T03:11:55 | 214,331,258 | 0 | 0 | MIT | 2020-06-11T04:50:30 | 2019-10-11T03:01:48 | C | UTF-8 | C | false | false | 2,028 | h | /**
* Implementation of an unweighted directed graph.
*
* Each vertex is identified by it's index in the graph's array of adjacency lists. This array's initial size can be chosen by the client (alternatively, default values can be used, hiding the internal details from the client). Note that when a vertex v has an ID greater than the graph's array of adjacency lists, the array must be expanded (memory reallocation). This might be improved later on through the use of hashing.
*
* @todo function to shrink the graph's array of adjacency lists to a desired size.
* @todo reduce, by the use of hashing, the memory required by the graph to store its adjacency lists.
*
* @version 1.0
* @author Gabriel Nogueira (Talendar)
*/
#ifndef UNWEIGHTED_DIGRAPH_H
#define UNWEIGHTED_DIGRAPH_H
#include <stdbool.h>
#include "singly_linked_list.h"
/* Constants */
static const int ADJ_LISTS_ARRAY_INITIAL_SIZE = 20; // the initial size of a graph's adjacency lists array
static const int ADJ_LISTS_ARRAY_DELTA_REALLOC = 10; // how much a graph's adjacency lists array will grow in each realloc
/* Structs */
typedef struct UnweightedDigraph Graph;
/* Create/Free */
Graph* graph_create_full(int initial_size, int delta_realloc);
Graph* graph_create();
void graph_free(Graph **g);
/* Insertions */
bool graph_add_vertex(Graph *g, int v);
bool graph_add_edge(Graph *g, int v, int w, bool create_if_needed);
/* Removals */
bool graph_remove_vertex(Graph *g, int v);
bool graph_remove_edge(Graph *g, int v, int w);
/* Queries */
int graph_num_vertices(Graph *g);
int graph_num_edges(Graph *g);
int graph_array_size(Graph *g);
bool graph_has_vertex(Graph *g, int v);
bool graph_has_cycle(Graph *g);
List* graph_find_sources(Graph *g);
int* graph_vertices(Graph *g);
int* graph_adj_to(Graph *g, int v);
int graph_adj_count(Graph *g, int v);
/* Others */
void graph_print(Graph *g);
#endif | [
"noreply@github.com"
] | Talendar.noreply@github.com |
1fb8d353805c47e03bdf05d07d5e9fc66cf0457d | 42de2e8f0cbc5dac7c960327b35d9e410047505c | /inputcontroller/trunk/source/unittest/InputRecorderTest.c | d5f4e28e63dad2c59b84f133b4b17ec879c51501 | [
"Zlib"
] | permissive | svn2github/libstem | cdbc9fc034fad62264b7d87a24d173a967645cf7 | 0b2bc5ff9240e825cc2aed399b57df993c83ba3d | refs/heads/master | 2020-04-04T23:13:26.084273 | 2019-01-19T22:26:05 | 2019-01-19T22:26:05 | 50,198,080 | 4 | 1 | null | null | null | null | UTF-8 | C | false | false | 13,619 | c | #include "inputcontroller/InputRecorder.h"
#include "unittest/TestSuite.h"
#include "utilities/IOUtilities.h"
#include "utilities/printfFormats.h"
#include <stdbool.h>
#include <unistd.h>
static void verifyInit(InputRecorder * inputRecorder, InputController * inputController, bool fileOutput, unsigned int lineNumber) {
TestCase_assert(inputRecorder != NULL, "Expected non-NULL but got NULL (%u)", lineNumber);
TestCase_assert(inputRecorder->dispose == InputRecorder_dispose, "Expected %p but got %p (%u)", InputRecorder_dispose, inputRecorder->dispose, lineNumber);
TestCase_assert(inputRecorder->inputController == inputController, "Expected %p but got %p (%u)", inputController, inputRecorder->inputController, lineNumber);
TestCase_assert(inputRecorder->frameIndex == 0, "Expected 0 but got %u (%u)", inputRecorder->frameIndex, lineNumber);
if (fileOutput) {
TestCase_assert(inputRecorder->outputFile != NULL, "Expected non-NULL but got NULL (%u)", lineNumber);
} else {
TestCase_assert(inputRecorder->outputFile == NULL, "Expected NULL but got %p (%u)", inputRecorder->outputFile, lineNumber);
TestCase_assert(inputRecorder->memwriteContext.realloc, "Expected true but got false (%u)", lineNumber);
}
}
static void testInit() {
InputRecorder inputRecorder, * inputRecorderPtr;
InputController * inputController;
const char * tempFilePath;
int tempFD;
inputController = InputController_create(NULL, NULL);
memset(&inputRecorder, 0x00, sizeof(InputRecorder));
InputRecorder_initWithMemwriteOutput(&inputRecorder, NULL, NULL, 0);
verifyInit(&inputRecorder, NULL, NULL, __LINE__);
InputRecorder_dispose(&inputRecorder);
memset(&inputRecorder, 0xFF, sizeof(InputRecorder));
InputRecorder_initWithMemwriteOutput(&inputRecorder, inputController, NULL, 0);
verifyInit(&inputRecorder, inputController, NULL, __LINE__);
InputRecorder_dispose(&inputRecorder);
inputRecorderPtr = InputRecorder_createWithMemwriteOutput(NULL, NULL, 0);
verifyInit(inputRecorderPtr, NULL, NULL, __LINE__);
InputRecorder_dispose(inputRecorderPtr);
tempFilePath = temporaryFilePath("tmpXXXXXX", &tempFD);
close(tempFD);
memset(&inputRecorder, 0x00, sizeof(InputRecorder));
InputRecorder_initWithFileOutput(&inputRecorder, NULL, NULL, 0, tempFilePath);
verifyInit(&inputRecorder, NULL, tempFilePath, __LINE__);
InputRecorder_dispose(&inputRecorder);
memset(&inputRecorder, 0xFF, sizeof(InputRecorder));
InputRecorder_initWithFileOutput(&inputRecorder, inputController, NULL, 0, tempFilePath);
verifyInit(&inputRecorder, inputController, tempFilePath, __LINE__);
InputRecorder_dispose(&inputRecorder);
inputRecorderPtr = InputRecorder_createWithFileOutput(NULL, NULL, 0, tempFilePath);
verifyInit(inputRecorderPtr, NULL, tempFilePath, __LINE__);
InputRecorder_dispose(inputRecorderPtr);
InputController_dispose(inputController);
unlink(tempFilePath);
}
static void testMemwriteRecording() {
InputRecorder * inputRecorder;
InputController * inputController;
inputController = InputController_create(NULL, NULL);
inputRecorder = InputRecorder_createWithMemwriteOutput(inputController, NULL, 0);
TestCase_assert(inputRecorder->memwriteContext.length == 8, "Expected 8 but got " SIZE_T_FORMAT, inputRecorder->memwriteContext.length);
TestCase_assert(!memcmp(inputRecorder->memwriteContext.data, "\x00\x00\x00\x00\x00\x00\x00\x00", 8), "Expected 0000 00000000 0000 but got %02X%02X %02X%02X%02X%02X %02X%02X", ((unsigned char *) inputRecorder->memwriteContext.data)[0], ((unsigned char *) inputRecorder->memwriteContext.data)[1], ((unsigned char *) inputRecorder->memwriteContext.data)[2], ((unsigned char *) inputRecorder->memwriteContext.data)[3], ((unsigned char *) inputRecorder->memwriteContext.data)[4], ((unsigned char *) inputRecorder->memwriteContext.data)[5], ((unsigned char *) inputRecorder->memwriteContext.data)[6], ((unsigned char *) inputRecorder->memwriteContext.data)[7]);
InputRecorder_dispose(inputRecorder);
inputRecorder = InputRecorder_createWithMemwriteOutput(inputController, "abcd", 4);
TestCase_assert(inputRecorder->memwriteContext.length == 12, "Expected 12 but got " SIZE_T_FORMAT, inputRecorder->memwriteContext.length);
TestCase_assert(!memcmp(inputRecorder->memwriteContext.data, "\x00\x00\x04\x00\x00\x00""abcd\x00\x00", 12), "Expected 0000 04000000 61626364 0000 but got %02X%02X %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X", ((unsigned char *) inputRecorder->memwriteContext.data)[0], ((unsigned char *) inputRecorder->memwriteContext.data)[1], ((unsigned char *) inputRecorder->memwriteContext.data)[2], ((unsigned char *) inputRecorder->memwriteContext.data)[3], ((unsigned char *) inputRecorder->memwriteContext.data)[4], ((unsigned char *) inputRecorder->memwriteContext.data)[5], ((unsigned char *) inputRecorder->memwriteContext.data)[6], ((unsigned char *) inputRecorder->memwriteContext.data)[7], ((unsigned char *) inputRecorder->memwriteContext.data)[8], ((unsigned char *) inputRecorder->memwriteContext.data)[9], ((unsigned char *) inputRecorder->memwriteContext.data)[10], ((unsigned char *) inputRecorder->memwriteContext.data)[11]);
InputRecorder_dispose(inputRecorder);
InputController_dispose(inputController);
inputController = InputController_create(NULL, "a", "bc", NULL);
inputRecorder = InputRecorder_createWithMemwriteOutput(inputController, NULL, 0);
TestCase_assert(inputRecorder->memwriteContext.length == 13, "Expected 13 but got " SIZE_T_FORMAT, inputRecorder->memwriteContext.length);
TestCase_assert(!memcmp(inputRecorder->memwriteContext.data, "\x00\x00\x00\x00\x00\x00\x02\x00""a\x00""bc\x00", 13), "Expected 0000 00000000 0200 6100 626300 but got %02X%02X %02X%02X%02X%02X %02X%02X %02X%02X %02X%02X%02X", ((unsigned char *) inputRecorder->memwriteContext.data)[0], ((unsigned char *) inputRecorder->memwriteContext.data)[1], ((unsigned char *) inputRecorder->memwriteContext.data)[2], ((unsigned char *) inputRecorder->memwriteContext.data)[3], ((unsigned char *) inputRecorder->memwriteContext.data)[4], ((unsigned char *) inputRecorder->memwriteContext.data)[5], ((unsigned char *) inputRecorder->memwriteContext.data)[6], ((unsigned char *) inputRecorder->memwriteContext.data)[7], ((unsigned char *) inputRecorder->memwriteContext.data)[8], ((unsigned char *) inputRecorder->memwriteContext.data)[9], ((unsigned char *) inputRecorder->memwriteContext.data)[10], ((unsigned char *) inputRecorder->memwriteContext.data)[11], ((unsigned char *) inputRecorder->memwriteContext.data)[12]);
inputController->triggerAction(inputController, ATOM("a"));
TestCase_assert(inputRecorder->memwriteContext.length == 19, "Expected 19 but got " SIZE_T_FORMAT, inputRecorder->memwriteContext.length);
TestCase_assert(!memcmp(inputRecorder->memwriteContext.data + 13, "\x00\x00\x00\x00\x00\x00", 6), "Expected 00000000 0000 but got %02X%02X%02X%02X %02X%02X", ((unsigned char *) inputRecorder->memwriteContext.data)[13], ((unsigned char *) inputRecorder->memwriteContext.data)[14], ((unsigned char *) inputRecorder->memwriteContext.data)[15], ((unsigned char *) inputRecorder->memwriteContext.data)[16], ((unsigned char *) inputRecorder->memwriteContext.data)[17], ((unsigned char *) inputRecorder->memwriteContext.data)[18]);
InputRecorder_nextFrame(inputRecorder);
inputController->triggerAction(inputController, ATOM("bc"));
TestCase_assert(inputRecorder->memwriteContext.length == 25, "Expected 25 but got " SIZE_T_FORMAT, inputRecorder->memwriteContext.length);
TestCase_assert(!memcmp(inputRecorder->memwriteContext.data + 19, "\x01\x00\x00\x00\x01\x00", 6), "Expected 01000000 0100 but got %02X%02X%02X%02X %02X%02X", ((unsigned char *) inputRecorder->memwriteContext.data)[19], ((unsigned char *) inputRecorder->memwriteContext.data)[20], ((unsigned char *) inputRecorder->memwriteContext.data)[21], ((unsigned char *) inputRecorder->memwriteContext.data)[22], ((unsigned char *) inputRecorder->memwriteContext.data)[23], ((unsigned char *) inputRecorder->memwriteContext.data)[24]);
InputRecorder_nextFrame(inputRecorder);
InputRecorder_nextFrame(inputRecorder);
InputRecorder_nextFrame(inputRecorder);
inputController->releaseAction(inputController, ATOM("bc"));
TestCase_assert(inputRecorder->memwriteContext.length == 31, "Expected 31 but got " SIZE_T_FORMAT, inputRecorder->memwriteContext.length);
TestCase_assert(!memcmp(inputRecorder->memwriteContext.data + 25, "\x03\x00\x00\x00\x01\x00", 6), "Expected 03000000 0100 but got %02X%02X%02X%02X %02X%02X", ((unsigned char *) inputRecorder->memwriteContext.data)[25], ((unsigned char *) inputRecorder->memwriteContext.data)[26], ((unsigned char *) inputRecorder->memwriteContext.data)[27], ((unsigned char *) inputRecorder->memwriteContext.data)[28], ((unsigned char *) inputRecorder->memwriteContext.data)[29], ((unsigned char *) inputRecorder->memwriteContext.data)[30]);
InputRecorder_dispose(inputRecorder);
InputController_dispose(inputController);
}
static void testFileRecording() {
InputRecorder * inputRecorder;
InputController * inputController;
const char * tempFilePath;
int tempFD;
unsigned char * fileContents;
size_t fileLength;
inputController = InputController_create(NULL, NULL);
tempFilePath = temporaryFilePath("tmpXXXXXX", &tempFD);
close(tempFD);
inputRecorder = InputRecorder_createWithFileOutput(inputController, NULL, 0, tempFilePath);
fileContents = readFileSimple(tempFilePath, &fileLength);
TestCase_assert(fileContents != NULL, "Expected non-NULL but got NULL");
TestCase_assert(fileLength == 8, "Expected 8 but got " SIZE_T_FORMAT, fileLength);
TestCase_assert(!memcmp(fileContents, "\x00\x00\x00\x00\x00\x00\x00\x00", 8), "Expected 0000 00000000 0000 but got %02X%02X %02X%02X%02X%02X %02X%02X", fileContents[0], fileContents[1], fileContents[2], fileContents[3], fileContents[4], fileContents[5], fileContents[6], fileContents[7]);
free(fileContents);
InputRecorder_dispose(inputRecorder);
inputRecorder = InputRecorder_createWithFileOutput(inputController, "abcd", 4, tempFilePath);
fileContents = readFileSimple(tempFilePath, &fileLength);
TestCase_assert(fileContents != NULL, "Expected non-NULL but got NULL");
TestCase_assert(fileLength == 12, "Expected 12 but got " SIZE_T_FORMAT, fileLength);
TestCase_assert(!memcmp(fileContents, "\x00\x00\x04\x00\x00\x00""abcd\x00\x00", 12), "Expected 0000 04000000 61626364 0000 but got %02X%02X %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X", fileContents[0], fileContents[1], fileContents[2], fileContents[3], fileContents[4], fileContents[5], fileContents[6], fileContents[7], fileContents[8], fileContents[9], fileContents[10], fileContents[11]);
free(fileContents);
InputRecorder_dispose(inputRecorder);
InputController_dispose(inputController);
inputController = InputController_create(NULL, "a", "bc", NULL);
inputRecorder = InputRecorder_createWithFileOutput(inputController, NULL, 0, tempFilePath);
fileContents = readFileSimple(tempFilePath, &fileLength);
TestCase_assert(fileContents != NULL, "Expected non-NULL but got NULL");
TestCase_assert(fileLength == 13, "Expected 13 but got " SIZE_T_FORMAT, fileLength);
TestCase_assert(!memcmp(fileContents, "\x00\x00\x00\x00\x00\x00\x02\x00""a\x00""bc\x00", 13), "Expected 0000 00000000 0200 6100 626300 but got %02X%02X %02X%02X%02X%02X %02X%02X %02X%02X %02X%02X%02X", fileContents[0], fileContents[1], fileContents[2], fileContents[3], fileContents[4], fileContents[5], fileContents[6], fileContents[7], fileContents[8], fileContents[9], fileContents[10], fileContents[11], fileContents[12]);
free(fileContents);
inputController->triggerAction(inputController, ATOM("a"));
fileContents = readFileSimple(tempFilePath, &fileLength);
TestCase_assert(fileContents != NULL, "Expected non-NULL but got NULL");
TestCase_assert(fileLength == 19, "Expected 19 but got " SIZE_T_FORMAT, fileLength);
TestCase_assert(!memcmp(fileContents + 13, "\x00\x00\x00\x00\x00\x00", 6), "Expected 00000000 0000 but got %02X%02X%02X%02X %02X%02X", fileContents[13], fileContents[14], fileContents[15], fileContents[16], fileContents[17], fileContents[18]);
free(fileContents);
InputRecorder_nextFrame(inputRecorder);
inputController->triggerAction(inputController, ATOM("bc"));
fileContents = readFileSimple(tempFilePath, &fileLength);
TestCase_assert(fileContents != NULL, "Expected non-NULL but got NULL");
TestCase_assert(fileLength == 25, "Expected 25 but got " SIZE_T_FORMAT, fileLength);
TestCase_assert(!memcmp(fileContents + 19, "\x01\x00\x00\x00\x01\x00", 6), "Expected 01000000 0100 but got %02X%02X%02X%02X %02X%02X", fileContents[19], fileContents[20], fileContents[21], fileContents[22], fileContents[23], fileContents[24]);
free(fileContents);
InputRecorder_nextFrame(inputRecorder);
InputRecorder_nextFrame(inputRecorder);
InputRecorder_nextFrame(inputRecorder);
inputController->releaseAction(inputController, ATOM("bc"));
fileContents = readFileSimple(tempFilePath, &fileLength);
TestCase_assert(fileContents != NULL, "Expected non-NULL but got NULL");
TestCase_assert(fileLength == 31, "Expected 31 but got " SIZE_T_FORMAT, fileLength);
TestCase_assert(!memcmp(fileContents + 25, "\x03\x00\x00\x00\x01\x00", 6), "Expected 03000000 0100 but got %02X%02X%02X%02X %02X%02X", fileContents[25], fileContents[26], fileContents[27], fileContents[28], fileContents[29], fileContents[30]);
free(fileContents);
InputRecorder_dispose(inputRecorder);
InputController_dispose(inputController);
unlink(tempFilePath);
}
TEST_SUITE(InputRecorderTest,
testInit,
testMemwriteRecording,
testFileRecording)
| [
"adiener@d291a34c-4c4d-0410-8556-a73de5c6a500"
] | adiener@d291a34c-4c4d-0410-8556-a73de5c6a500 |
83ba643aa8efd849d72c794e33cbb14394400790 | ddca3a85f04f03525c043c3b63835dc385b46804 | /e2ap/headers/Cause.h | b088d2bc1e33a7eebc9006e538df56d5c3d6b4d7 | [
"Apache-2.0"
] | permissive | heqzha/ric-xapp-kpimon | 417230eb3d1b53b3c41133ab78ae164524198d17 | 2dcef8158e957c46ae94626c7fa7162de43c4115 | refs/heads/master | 2023-06-11T18:22:20.691801 | 2021-07-02T13:26:32 | 2021-07-02T13:26:32 | 382,063,591 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,544 | h | /*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "E2AP-IEs"
* found in "E2AP-IEs-v01.00.asn"
* `asn1c -pdu=auto -fno-include-deps -fcompound-names -findirect-choice -gen-PER -gen-OER -no-gen-example`
*/
#ifndef _Cause_H_
#define _Cause_H_
#include <asn_application.h>
/* Including external dependencies */
#include "CauseRIC.h"
#include "CauseRICservice.h"
#include "CauseTransport.h"
#include "CauseProtocol.h"
#include "CauseMisc.h"
#include <constr_CHOICE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum Cause_PR {
Cause_PR_NOTHING, /* No components present */
Cause_PR_ricRequest,
Cause_PR_ricService,
Cause_PR_transport,
Cause_PR_protocol,
Cause_PR_misc
/* Extensions may appear below */
} Cause_PR;
/* Cause */
typedef struct Cause {
Cause_PR present;
union Cause_u {
CauseRIC_t ricRequest;
CauseRICservice_t ricService;
CauseTransport_t transport;
CauseProtocol_t protocol;
CauseMisc_t misc;
/*
* This type is extensible,
* possible extensions are below.
*/
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Cause_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_Cause;
extern asn_CHOICE_specifics_t asn_SPC_Cause_specs_1;
extern asn_TYPE_member_t asn_MBR_Cause_1[5];
extern asn_per_constraints_t asn_PER_type_Cause_constr_1;
#ifdef __cplusplus
}
#endif
#endif /* _Cause_H_ */
#include <asn_internal.h>
| [
"jinwei.fan@samsung.com"
] | jinwei.fan@samsung.com |
8c55a9d8721213e6d204d7b34bdf21a1cb98f69e | f6ea478c1c516bc560fd8ce45677677508c4e377 | /jni/VGMStreamPlugin/vgmstream/layout/xa_blocked.c | e84cb15b4f2d4026fafd4bba92f122dbd996e70f | [
"ISC",
"LicenseRef-scancode-public-domain"
] | permissive | srolemberg/Droidsound | 13bc9c4bbd1d3b6cc825d85b20b34ea967e7b639 | 7837a5e048baf42d56b04b1eff55d5bba25205ab | refs/heads/master | 2020-09-25T05:08:48.027386 | 2019-12-02T16:25:41 | 2019-12-02T16:25:41 | 151,464,546 | 1 | 0 | NOASSERTION | 2018-10-03T18:57:59 | 2018-10-03T18:57:59 | null | UTF-8 | C | false | false | 1,540 | c | #include "layout.h"
#include "../coding/coding.h"
#include "../vgmstream.h"
/* set up for the block at the given offset */
void xa_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
int i;
int8_t currentChannel=0;
int8_t subAudio=0;
init_get_high_nibble(vgmstream);
if(vgmstream->samples_into_block!=0)
// don't change this variable in the init process
vgmstream->xa_sector_length+=128;
// We get to the end of a sector ?
if(vgmstream->xa_sector_length==(18*128)) {
vgmstream->xa_sector_length=0;
// 0x30 of unused bytes/sector :(
if (!vgmstream->xa_headerless) {
block_offset+=0x30;
begin:
// Search for selected channel & valid audio
currentChannel=read_8bit(block_offset-7,vgmstream->ch[0].streamfile);
subAudio=read_8bit(block_offset-6,vgmstream->ch[0].streamfile);
// audio is coded as 0x64
if(!((subAudio==0x64) && (currentChannel==vgmstream->xa_channel))) {
// go to next sector
block_offset+=2352;
if(currentChannel!=-1) goto begin;
}
}
}
vgmstream->current_block_offset = block_offset;
// Quid : how to stop the current channel ???
// i set up 0 to current_block_size to make vgmstream not playing bad samples
// another way to do it ???
// (as the number of samples can be false in cd-xa due to multi-channels)
vgmstream->current_block_size = (currentChannel==-1?0:112);
vgmstream->next_block_offset = vgmstream->current_block_offset+128;
for (i=0;i<vgmstream->channels;i++) {
vgmstream->ch[i].offset = vgmstream->current_block_offset;
}
}
| [
"droidmjt@gmail.com"
] | droidmjt@gmail.com |
d6d1b9b526189165b88ff1c2e2ecc3ac6e0cc415 | 940d7b93fb27e8eead9b6e52bc5c7444666744dd | /python/src/Modules/_ctypes/libffi/src/cris/ffi.c | e9c39530c22137a0add323527d3085fb4ae69e9c | [
"Apache-2.0",
"GPL-1.0-or-later",
"LicenseRef-scancode-other-copyleft",
"Python-2.0",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-python-cwi",
"MIT"
] | permissive | pilotx45/sl4a | d446531d310cc17d93f24aab7271a0813e8f628d | 150e3e46b5103a9b9a391034ef3fbc5bd5160d0f | refs/heads/master | 2022-03-24T19:48:30.340479 | 2022-03-08T16:23:58 | 2022-03-08T16:23:58 | 277,016,574 | 1 | 0 | Apache-2.0 | 2022-03-08T16:23:59 | 2020-07-04T01:25:36 | null | UTF-8 | C | false | false | 9,658 | c | /* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Cygnus Solutions
Copyright (c) 2004 Simon Posnjak
Copyright (c) 2005 Axis Communications AB
Copyright (C) 2007 Free Software Foundation, Inc.
CRIS Foreign Function Interface
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 SIMON POSNJAK 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 <ffi.h>
#include <ffi_common.h>
#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
static ffi_status
initialize_aggregate_packed_struct (ffi_type * arg)
{
ffi_type **ptr;
FFI_ASSERT (arg != NULL);
FFI_ASSERT (arg->elements != NULL);
FFI_ASSERT (arg->size == 0);
FFI_ASSERT (arg->alignment == 0);
ptr = &(arg->elements[0]);
while ((*ptr) != NULL)
{
if (((*ptr)->size == 0)
&& (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK))
return FFI_BAD_TYPEDEF;
FFI_ASSERT (ffi_type_test ((*ptr)));
arg->size += (*ptr)->size;
arg->alignment = (arg->alignment > (*ptr)->alignment) ?
arg->alignment : (*ptr)->alignment;
ptr++;
}
if (arg->size == 0)
return FFI_BAD_TYPEDEF;
else
return FFI_OK;
}
int
ffi_prep_args (char *stack, extended_cif * ecif)
{
unsigned int i;
unsigned int struct_count = 0;
void **p_argv;
char *argp;
ffi_type **p_arg;
argp = stack;
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0); i--, p_arg++)
{
size_t z;
switch ((*p_arg)->type)
{
case FFI_TYPE_STRUCT:
{
z = (*p_arg)->size;
if (z <= 4)
{
memcpy (argp, *p_argv, z);
z = 4;
}
else if (z <= 8)
{
memcpy (argp, *p_argv, z);
z = 8;
}
else
{
unsigned int uiLocOnStack;
z = sizeof (void *);
uiLocOnStack = 4 * ecif->cif->nargs + struct_count;
struct_count = struct_count + (*p_arg)->size;
*(unsigned int *) argp =
(unsigned int) (UINT32 *) (stack + uiLocOnStack);
memcpy ((stack + uiLocOnStack), *p_argv, (*p_arg)->size);
}
break;
}
default:
z = (*p_arg)->size;
if (z < sizeof (int))
{
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int) *(SINT8 *) (*p_argv);
break;
case FFI_TYPE_UINT8:
*(unsigned int *) argp =
(unsigned int) *(UINT8 *) (*p_argv);
break;
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int) *(SINT16 *) (*p_argv);
break;
case FFI_TYPE_UINT16:
*(unsigned int *) argp =
(unsigned int) *(UINT16 *) (*p_argv);
break;
default:
FFI_ASSERT (0);
}
z = sizeof (int);
}
else if (z == sizeof (int))
*(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv);
else
memcpy (argp, *p_argv, z);
break;
}
p_argv++;
argp += z;
}
return (struct_count);
}
ffi_status
ffi_prep_cif (ffi_cif * cif,
ffi_abi abi, unsigned int nargs,
ffi_type * rtype, ffi_type ** atypes)
{
unsigned bytes = 0;
unsigned int i;
ffi_type **ptr;
FFI_ASSERT (cif != NULL);
FFI_ASSERT ((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
cif->abi = abi;
cif->arg_types = atypes;
cif->nargs = nargs;
cif->rtype = rtype;
cif->flags = 0;
if ((cif->rtype->size == 0)
&& (initialize_aggregate_packed_struct (cif->rtype) != FFI_OK))
return FFI_BAD_TYPEDEF;
FFI_ASSERT_VALID_TYPE (cif->rtype);
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
{
if (((*ptr)->size == 0)
&& (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK))
return FFI_BAD_TYPEDEF;
FFI_ASSERT_VALID_TYPE (*ptr);
if (((*ptr)->alignment - 1) & bytes)
bytes = ALIGN (bytes, (*ptr)->alignment);
if ((*ptr)->type == FFI_TYPE_STRUCT)
{
if ((*ptr)->size > 8)
{
bytes += (*ptr)->size;
bytes += sizeof (void *);
}
else
{
if ((*ptr)->size > 4)
bytes += 8;
else
bytes += 4;
}
}
else
bytes += STACK_ARG_SIZE ((*ptr)->size);
}
cif->bytes = bytes;
return ffi_prep_cif_machdep (cif);
}
ffi_status
ffi_prep_cif_machdep (ffi_cif * cif)
{
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
case FFI_TYPE_STRUCT:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
cif->flags = (unsigned) cif->rtype->type;
break;
default:
cif->flags = FFI_TYPE_INT;
break;
}
return FFI_OK;
}
extern void ffi_call_SYSV (int (*)(char *, extended_cif *),
extended_cif *,
unsigned, unsigned, unsigned *, void (*fn) ())
__attribute__ ((__visibility__ ("hidden")));
void
ffi_call (ffi_cif * cif, void (*fn) (), void *rvalue, void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT))
{
ecif.rvalue = alloca (cif->rtype->size);
}
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV (ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
break;
default:
FFI_ASSERT (0);
break;
}
}
/* Because the following variables are not exported outside libffi, we
mark them hidden. */
/* Assembly code for the jump stub. */
extern const char ffi_cris_trampoline_template[]
__attribute__ ((__visibility__ ("hidden")));
/* Offset into ffi_cris_trampoline_template of where to put the
ffi_prep_closure_inner function. */
extern const int ffi_cris_trampoline_fn_offset
__attribute__ ((__visibility__ ("hidden")));
/* Offset into ffi_cris_trampoline_template of where to put the
closure data. */
extern const int ffi_cris_trampoline_closure_offset
__attribute__ ((__visibility__ ("hidden")));
/* This function is sibling-called (jumped to) by the closure
trampoline. We get R10..R13 at PARAMS[0..3] and a copy of [SP] at
PARAMS[4] to simplify handling of a straddling parameter. A copy
of R9 is at PARAMS[5] and SP at PARAMS[6]. These parameters are
put at the appropriate place in CLOSURE which is then executed and
the return value is passed back to the caller. */
static unsigned long long
ffi_prep_closure_inner (void **params, ffi_closure* closure)
{
char *register_args = (char *) params;
void *struct_ret = params[5];
char *stack_args = params[6];
char *ptr = register_args;
ffi_cif *cif = closure->cif;
ffi_type **arg_types = cif->arg_types;
/* Max room needed is number of arguments as 64-bit values. */
void **avalue = alloca (closure->cif->nargs * sizeof(void *));
int i;
int doing_regs;
long long llret = 0;
/* Find the address of each argument. */
for (i = 0, doing_regs = 1; i < cif->nargs; i++)
{
/* Types up to and including 8 bytes go by-value. */
if (arg_types[i]->size <= 4)
{
avalue[i] = ptr;
ptr += 4;
}
else if (arg_types[i]->size <= 8)
{
avalue[i] = ptr;
ptr += 8;
}
else
{
FFI_ASSERT (arg_types[i]->type == FFI_TYPE_STRUCT);
/* Passed by-reference, so copy the pointer. */
avalue[i] = *(void **) ptr;
ptr += 4;
}
/* If we've handled more arguments than fit in registers, start
looking at the those passed on the stack. Step over the
first one if we had a straddling parameter. */
if (doing_regs && ptr >= register_args + 4*4)
{
ptr = stack_args + ((ptr > register_args + 4*4) ? 4 : 0);
doing_regs = 0;
}
}
/* Invoke the closure. */
(closure->fun) (cif,
cif->rtype->type == FFI_TYPE_STRUCT
/* The caller allocated space for the return
structure, and passed a pointer to this space in
R9. */
? struct_ret
/* We take advantage of being able to ignore that
the high part isn't set if the return value is
not in R10:R11, but in R10 only. */
: (void *) &llret,
avalue, closure->user_data);
return llret;
}
/* API function: Prepare the trampoline. */
ffi_status
ffi_prep_closure_loc (ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif *, void *, void **, void*),
void *user_data,
void *codeloc)
{
void *innerfn = ffi_prep_closure_inner;
FFI_ASSERT (cif->abi == FFI_SYSV);
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
memcpy (closure->tramp, ffi_cris_trampoline_template,
FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE);
memcpy (closure->tramp + ffi_cris_trampoline_fn_offset,
&innerfn, sizeof (void *));
memcpy (closure->tramp + ffi_cris_trampoline_closure_offset,
&codeloc, sizeof (void *));
return FFI_OK;
}
| [
"damonkohler@gmail.com"
] | damonkohler@gmail.com |
43686216573077fabf46a814352b69ddfd8dd964 | 0fe7902ce690e031dcfaf031eec3b75afc8e2b08 | /srcs/libft/srcs/ft_putstr.c | 3307d5c7c01849d33aee5f2f303a86343de62b43 | [] | no_license | schevall/Filler | 7a2ee0733a975e0212ba71022f377f36163e6f5b | dded3ad01d56e0d1ed8b75d50a6f7c4ce055c7a2 | refs/heads/master | 2021-08-11T08:22:50.833332 | 2017-11-13T11:45:28 | 2017-11-13T11:45:28 | 108,243,798 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,014 | c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: schevall <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/17 13:03:41 by schevall #+# #+# */
/* Updated: 2017/03/06 18:17:00 by schevall ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/libft.h"
void ft_putstr(char const *str)
{
if (str)
{
while (*str)
write(1, str++, 1);
}
}
| [
"sim.chvll@gmail.com"
] | sim.chvll@gmail.com |
3fdf0c897f9c966d68c442fe965bf6c1d2ae2c44 | de8c0ea84980b6d9bb6e3e23b87e6066a65f4995 | /3pp/linux/include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 3d46907bab89ce0eb576a0fa97a5fa59c6b7de49 | [
"GPL-2.0-only",
"MIT",
"Linux-syscall-note"
] | permissive | eerimoq/monolinux-example-project | 7cc19c6fc179a6d1fd3ec60f383f906b727e6715 | 57c4c2928b11cc04db59fb5ced962762099a9895 | refs/heads/master | 2021-02-08T10:57:58.215466 | 2020-07-02T08:04:25 | 2020-07-02T08:04:25 | 244,144,570 | 6 | 0 | MIT | 2020-07-02T08:15:50 | 2020-03-01T12:24:47 | C | UTF-8 | C | false | false | 1,355 | h | /* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2015 Freescale Semiconductor, Inc.
*/
#ifndef __LINUX_IMX7_IOMUXC_GPR_H
#define __LINUX_IMX7_IOMUXC_GPR_H
#define IOMUXC_GPR0 0x00
#define IOMUXC_GPR1 0x04
#define IOMUXC_GPR2 0x08
#define IOMUXC_GPR3 0x0c
#define IOMUXC_GPR4 0x10
#define IOMUXC_GPR5 0x14
#define IOMUXC_GPR6 0x18
#define IOMUXC_GPR7 0x1c
#define IOMUXC_GPR8 0x20
#define IOMUXC_GPR9 0x24
#define IOMUXC_GPR10 0x28
#define IOMUXC_GPR11 0x2c
#define IOMUXC_GPR12 0x30
#define IOMUXC_GPR13 0x34
#define IOMUXC_GPR14 0x38
#define IOMUXC_GPR15 0x3c
#define IOMUXC_GPR16 0x40
#define IOMUXC_GPR17 0x44
#define IOMUXC_GPR18 0x48
#define IOMUXC_GPR19 0x4c
#define IOMUXC_GPR20 0x50
#define IOMUXC_GPR21 0x54
#define IOMUXC_GPR22 0x58
/* For imx7d iomux gpr register field define */
#define IMX7D_GPR1_IRQ_MASK (0x1 << 12)
#define IMX7D_GPR1_ENET1_TX_CLK_SEL_MASK (0x1 << 13)
#define IMX7D_GPR1_ENET2_TX_CLK_SEL_MASK (0x1 << 14)
#define IMX7D_GPR1_ENET_TX_CLK_SEL_MASK (0x3 << 13)
#define IMX7D_GPR1_ENET1_CLK_DIR_MASK (0x1 << 17)
#define IMX7D_GPR1_ENET2_CLK_DIR_MASK (0x1 << 18)
#define IMX7D_GPR1_ENET_CLK_DIR_MASK (0x3 << 17)
#define IMX7D_GPR5_CSI_MUX_CONTROL_MIPI (0x1 << 4)
#define IMX7D_GPR12_PCIE_PHY_REFCLK_SEL BIT(5)
#define IMX7D_GPR22_PCIE_PHY_PLL_LOCKED BIT(31)
#endif /* __LINUX_IMX7_IOMUXC_GPR_H */
| [
"erik.moqvist@gmail.com"
] | erik.moqvist@gmail.com |
ce327317899ceb28326f282171f44eb73bd624c5 | 488378d66dfb12d3292886b160243aa24e27c420 | /linux-3.16/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 8f04817cb7ec810bc70dea859895788fd9259687 | [
"GPL-1.0-or-later",
"Linux-syscall-note",
"GPL-2.0-only",
"Unlicense",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | jj1232727/system_call | 3ec72bdecad15a43638cc5eb91ba1ae229d651bb | 145315cdf532c45b6aa753d98260d2b1c0b63abc | refs/heads/master | 2020-08-11T13:56:16.335620 | 2019-10-12T11:12:53 | 2019-10-12T11:12:53 | 214,575,269 | 0 | 0 | Unlicense | 2019-10-12T04:06:22 | 2019-10-12T04:06:22 | null | UTF-8 | C | false | false | 20,122 | c | /******************************************************************************
*
* Copyright(c) 2009-2012 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
* Hsinchu 300, Taiwan.
*
* Larry Finger <Larry.Finger@lwfinger.net>
*
*****************************************************************************/
#include "../wifi.h"
#include "../pci.h"
#include "../base.h"
#include "../stats.h"
#include "reg.h"
#include "def.h"
#include "phy.h"
#include "trx.h"
#include "led.h"
static u8 _rtl92ce_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
{
__le16 fc = rtl_get_fc(skb);
if (unlikely(ieee80211_is_beacon(fc)))
return QSLT_BEACON;
if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc))
return QSLT_MGNT;
return skb->priority;
}
static u8 _rtl92c_query_rxpwrpercentage(char antpower)
{
if ((antpower <= -100) || (antpower >= 20))
return 0;
else if (antpower >= 0)
return 100;
else
return 100 + antpower;
}
static u8 _rtl92c_evm_db_to_percentage(char value)
{
char ret_val;
ret_val = value;
if (ret_val >= 0)
ret_val = 0;
if (ret_val <= -33)
ret_val = -33;
ret_val = 0 - ret_val;
ret_val *= 3;
if (ret_val == 99)
ret_val = 100;
return ret_val;
}
static long _rtl92ce_signal_scale_mapping(struct ieee80211_hw *hw,
long currsig)
{
long retsig;
if (currsig >= 61 && currsig <= 100)
retsig = 90 + ((currsig - 60) / 4);
else if (currsig >= 41 && currsig <= 60)
retsig = 78 + ((currsig - 40) / 2);
else if (currsig >= 31 && currsig <= 40)
retsig = 66 + (currsig - 30);
else if (currsig >= 21 && currsig <= 30)
retsig = 54 + (currsig - 20);
else if (currsig >= 5 && currsig <= 20)
retsig = 42 + (((currsig - 5) * 2) / 3);
else if (currsig == 4)
retsig = 36;
else if (currsig == 3)
retsig = 27;
else if (currsig == 2)
retsig = 18;
else if (currsig == 1)
retsig = 9;
else
retsig = currsig;
return retsig;
}
static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
struct rtl_stats *pstats,
struct rx_desc_92c *pdesc,
struct rx_fwinfo_92c *p_drvinfo,
bool packet_match_bssid,
bool packet_toself,
bool packet_beacon)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct phy_sts_cck_8192s_t *cck_buf;
struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
s8 rx_pwr_all = 0, rx_pwr[4];
u8 evm, pwdb_all, rf_rx_num = 0;
u8 i, max_spatial_stream;
u32 rssi, total_rssi = 0;
bool is_cck_rate;
is_cck_rate = RX_HAL_IS_CCK_RATE(pdesc);
pstats->packet_matchbssid = packet_match_bssid;
pstats->packet_toself = packet_toself;
pstats->is_cck = is_cck_rate;
pstats->packet_beacon = packet_beacon;
pstats->rx_mimo_sig_qual[0] = -1;
pstats->rx_mimo_sig_qual[1] = -1;
if (is_cck_rate) {
u8 report, cck_highpwr;
cck_buf = (struct phy_sts_cck_8192s_t *)p_drvinfo;
if (ppsc->rfpwr_state == ERFON)
cck_highpwr = (u8) rtl_get_bbreg(hw,
RFPGA0_XA_HSSIPARAMETER2,
BIT(9));
else
cck_highpwr = false;
if (!cck_highpwr) {
u8 cck_agc_rpt = cck_buf->cck_agc_rpt;
report = cck_buf->cck_agc_rpt & 0xc0;
report = report >> 6;
switch (report) {
case 0x3:
rx_pwr_all = -46 - (cck_agc_rpt & 0x3e);
break;
case 0x2:
rx_pwr_all = -26 - (cck_agc_rpt & 0x3e);
break;
case 0x1:
rx_pwr_all = -12 - (cck_agc_rpt & 0x3e);
break;
case 0x0:
rx_pwr_all = 16 - (cck_agc_rpt & 0x3e);
break;
}
} else {
u8 cck_agc_rpt = cck_buf->cck_agc_rpt;
report = p_drvinfo->cfosho[0] & 0x60;
report = report >> 5;
switch (report) {
case 0x3:
rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f) << 1);
break;
case 0x2:
rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f) << 1);
break;
case 0x1:
rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f) << 1);
break;
case 0x0:
rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f) << 1);
break;
}
}
pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
/* CCK gain is smaller than OFDM/MCS gain,
* so we add gain diff by experiences,
* the val is 6
*/
pwdb_all += 6;
if (pwdb_all > 100)
pwdb_all = 100;
/* modify the offset to make the same
* gain index with OFDM.
*/
if (pwdb_all > 34 && pwdb_all <= 42)
pwdb_all -= 2;
else if (pwdb_all > 26 && pwdb_all <= 34)
pwdb_all -= 6;
else if (pwdb_all > 14 && pwdb_all <= 26)
pwdb_all -= 8;
else if (pwdb_all > 4 && pwdb_all <= 14)
pwdb_all -= 4;
pstats->rx_pwdb_all = pwdb_all;
pstats->recvsignalpower = rx_pwr_all;
/* (3) Get Signal Quality (EVM) */
if (packet_match_bssid) {
u8 sq;
if (pstats->rx_pwdb_all > 40)
sq = 100;
else {
sq = cck_buf->sq_rpt;
if (sq > 64)
sq = 0;
else if (sq < 20)
sq = 100;
else
sq = ((64 - sq) * 100) / 44;
}
pstats->signalquality = sq;
pstats->rx_mimo_sig_qual[0] = sq;
pstats->rx_mimo_sig_qual[1] = -1;
}
} else {
rtlpriv->dm.rfpath_rxenable[0] =
rtlpriv->dm.rfpath_rxenable[1] = true;
/* (1)Get RSSI for HT rate */
for (i = RF90_PATH_A; i < RF90_PATH_MAX; i++) {
/* we will judge RF RX path now. */
if (rtlpriv->dm.rfpath_rxenable[i])
rf_rx_num++;
rx_pwr[i] =
((p_drvinfo->gain_trsw[i] & 0x3f) * 2) - 110;
/* Translate DBM to percentage. */
rssi = _rtl92c_query_rxpwrpercentage(rx_pwr[i]);
total_rssi += rssi;
/* Get Rx snr value in DB */
rtlpriv->stats.rx_snr_db[i] =
(long)(p_drvinfo->rxsnr[i] / 2);
/* Record Signal Strength for next packet */
if (packet_match_bssid)
pstats->rx_mimo_signalstrength[i] = (u8) rssi;
}
/* (2)PWDB, Average PWDB cacluated by
* hardware (for rate adaptive)
*/
rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 110;
pwdb_all = _rtl92c_query_rxpwrpercentage(rx_pwr_all);
pstats->rx_pwdb_all = pwdb_all;
pstats->rxpower = rx_pwr_all;
pstats->recvsignalpower = rx_pwr_all;
/* (3)EVM of HT rate */
if (pstats->is_ht && pstats->rate >= DESC92_RATEMCS8 &&
pstats->rate <= DESC92_RATEMCS15)
max_spatial_stream = 2;
else
max_spatial_stream = 1;
for (i = 0; i < max_spatial_stream; i++) {
evm = _rtl92c_evm_db_to_percentage(p_drvinfo->rxevm[i]);
if (packet_match_bssid) {
/* Fill value in RFD, Get the first
* spatial stream only
*/
if (i == 0)
pstats->signalquality =
(u8) (evm & 0xff);
pstats->rx_mimo_sig_qual[i] = (u8) (evm & 0xff);
}
}
}
/* UI BSS List signal strength(in percentage),
* make it good looking, from 0~100.
*/
if (is_cck_rate)
pstats->signalstrength =
(u8) (_rtl92ce_signal_scale_mapping(hw, pwdb_all));
else if (rf_rx_num != 0)
pstats->signalstrength =
(u8) (_rtl92ce_signal_scale_mapping
(hw, total_rssi /= rf_rx_num));
}
static void _rtl92ce_translate_rx_signal_stuff(struct ieee80211_hw *hw,
struct sk_buff *skb,
struct rtl_stats *pstats,
struct rx_desc_92c *pdesc,
struct rx_fwinfo_92c *p_drvinfo)
{
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
struct ieee80211_hdr *hdr;
u8 *tmp_buf;
u8 *praddr;
__le16 fc;
u16 type, c_fc;
bool packet_matchbssid, packet_toself, packet_beacon = false;
tmp_buf = skb->data + pstats->rx_drvinfo_size + pstats->rx_bufshift;
hdr = (struct ieee80211_hdr *)tmp_buf;
fc = hdr->frame_control;
c_fc = le16_to_cpu(fc);
type = WLAN_FC_GET_TYPE(fc);
praddr = hdr->addr1;
packet_matchbssid =
((IEEE80211_FTYPE_CTL != type) &&
ether_addr_equal(mac->bssid,
(c_fc & IEEE80211_FCTL_TODS) ? hdr->addr1 :
(c_fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 :
hdr->addr3) &&
(!pstats->hwerror) && (!pstats->crc) && (!pstats->icv));
packet_toself = packet_matchbssid &&
ether_addr_equal(praddr, rtlefuse->dev_addr);
if (ieee80211_is_beacon(fc))
packet_beacon = true;
_rtl92ce_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
packet_matchbssid, packet_toself,
packet_beacon);
rtl_process_phyinfo(hw, tmp_buf, pstats);
}
bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
struct rtl_stats *stats,
struct ieee80211_rx_status *rx_status,
u8 *p_desc, struct sk_buff *skb)
{
struct rx_fwinfo_92c *p_drvinfo;
struct rx_desc_92c *pdesc = (struct rx_desc_92c *)p_desc;
struct ieee80211_hdr *hdr;
u32 phystatus = GET_RX_DESC_PHYST(pdesc);
stats->length = (u16) GET_RX_DESC_PKT_LEN(pdesc);
stats->rx_drvinfo_size = (u8) GET_RX_DESC_DRV_INFO_SIZE(pdesc) *
RX_DRV_INFO_SIZE_UNIT;
stats->rx_bufshift = (u8) (GET_RX_DESC_SHIFT(pdesc) & 0x03);
stats->icv = (u16) GET_RX_DESC_ICV(pdesc);
stats->crc = (u16) GET_RX_DESC_CRC32(pdesc);
stats->hwerror = (stats->crc | stats->icv);
stats->decrypted = !GET_RX_DESC_SWDEC(pdesc);
stats->rate = (u8) GET_RX_DESC_RXMCS(pdesc);
stats->shortpreamble = (u16) GET_RX_DESC_SPLCP(pdesc);
stats->isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1);
stats->isfirst_ampdu = (bool) ((GET_RX_DESC_PAGGR(pdesc) == 1)
&& (GET_RX_DESC_FAGGR(pdesc) == 1));
stats->timestamp_low = GET_RX_DESC_TSFL(pdesc);
stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc);
stats->is_ht = (bool)GET_RX_DESC_RXHT(pdesc);
stats->is_cck = RX_HAL_IS_CCK_RATE(pdesc);
rx_status->freq = hw->conf.chandef.chan->center_freq;
rx_status->band = hw->conf.chandef.chan->band;
hdr = (struct ieee80211_hdr *)(skb->data + stats->rx_drvinfo_size
+ stats->rx_bufshift);
if (stats->crc)
rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
if (stats->rx_is40Mhzpacket)
rx_status->flag |= RX_FLAG_40MHZ;
if (stats->is_ht)
rx_status->flag |= RX_FLAG_HT;
rx_status->flag |= RX_FLAG_MACTIME_START;
/* hw will set stats->decrypted true, if it finds the
* frame is open data frame or mgmt frame.
* So hw will not decryption robust managment frame
* for IEEE80211w but still set status->decrypted
* true, so here we should set it back to undecrypted
* for IEEE80211w frame, and mac80211 sw will help
* to decrypt it
*/
if (stats->decrypted) {
if (!hdr) {
/* In testing, hdr was NULL here */
return false;
}
if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
(ieee80211_has_protected(hdr->frame_control)))
rx_status->flag &= ~RX_FLAG_DECRYPTED;
else
rx_status->flag |= RX_FLAG_DECRYPTED;
}
/* rate_idx: index of data rate into band's
* supported rates or MCS index if HT rates
* are use (RX_FLAG_HT)
* Notice: this is diff with windows define
*/
rx_status->rate_idx = rtlwifi_rate_mapping(hw,
stats->is_ht, stats->rate,
stats->isfirst_ampdu);
rx_status->mactime = stats->timestamp_low;
if (phystatus) {
p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
stats->rx_bufshift);
_rtl92ce_translate_rx_signal_stuff(hw,
skb, stats, pdesc,
p_drvinfo);
}
/*rx_status->qual = stats->signal; */
rx_status->signal = stats->recvsignalpower + 10;
return true;
}
void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
struct ieee80211_hdr *hdr, u8 *pdesc_tx,
u8 *pbd_desc_tx, struct ieee80211_tx_info *info,
struct ieee80211_sta *sta,
struct sk_buff *skb,
u8 hw_queue, struct rtl_tcb_desc *tcb_desc)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
bool defaultadapter = true;
u8 *pdesc = pdesc_tx;
u16 seq_number;
__le16 fc = hdr->frame_control;
u8 fw_qsel = _rtl92ce_map_hwqueue_to_fwqueue(skb, hw_queue);
bool firstseg = ((hdr->seq_ctrl &
cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0);
bool lastseg = ((hdr->frame_control &
cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0);
dma_addr_t mapping = pci_map_single(rtlpci->pdev,
skb->data, skb->len,
PCI_DMA_TODEVICE);
u8 bw_40 = 0;
if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
"DMA mapping error");
return;
}
rcu_read_lock();
sta = get_sta(hw, mac->vif, mac->bssid);
if (mac->opmode == NL80211_IFTYPE_STATION) {
bw_40 = mac->bw_40;
} else if (mac->opmode == NL80211_IFTYPE_AP ||
mac->opmode == NL80211_IFTYPE_ADHOC ||
mac->opmode == NL80211_IFTYPE_MESH_POINT) {
if (sta)
bw_40 = sta->bandwidth >= IEEE80211_STA_RX_BW_40;
}
seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
rtl_get_tcb_desc(hw, info, sta, skb, tcb_desc);
CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_92c));
if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) {
firstseg = true;
lastseg = true;
}
if (firstseg) {
SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
SET_TX_DESC_TX_RATE(pdesc, tcb_desc->hw_rate);
if (tcb_desc->use_shortgi || tcb_desc->use_shortpreamble)
SET_TX_DESC_DATA_SHORTGI(pdesc, 1);
if (info->flags & IEEE80211_TX_CTL_AMPDU) {
SET_TX_DESC_AGG_BREAK(pdesc, 1);
SET_TX_DESC_MAX_AGG_NUM(pdesc, 0x14);
}
SET_TX_DESC_SEQ(pdesc, seq_number);
SET_TX_DESC_RTS_ENABLE(pdesc, ((tcb_desc->rts_enable &&
!tcb_desc->
cts_enable) ? 1 : 0));
SET_TX_DESC_HW_RTS_ENABLE(pdesc,
((tcb_desc->rts_enable
|| tcb_desc->cts_enable) ? 1 : 0));
SET_TX_DESC_CTS2SELF(pdesc, ((tcb_desc->cts_enable) ? 1 : 0));
SET_TX_DESC_RTS_STBC(pdesc, ((tcb_desc->rts_stbc) ? 1 : 0));
SET_TX_DESC_RTS_RATE(pdesc, tcb_desc->rts_rate);
SET_TX_DESC_RTS_BW(pdesc, 0);
SET_TX_DESC_RTS_SC(pdesc, tcb_desc->rts_sc);
SET_TX_DESC_RTS_SHORT(pdesc,
((tcb_desc->rts_rate <= DESC92_RATE54M) ?
(tcb_desc->rts_use_shortpreamble ? 1 : 0)
: (tcb_desc->rts_use_shortgi ? 1 : 0)));
if (bw_40) {
if (tcb_desc->packet_bw) {
SET_TX_DESC_DATA_BW(pdesc, 1);
SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3);
} else {
SET_TX_DESC_DATA_BW(pdesc, 0);
SET_TX_DESC_TX_SUB_CARRIER(pdesc,
mac->cur_40_prime_sc);
}
} else {
SET_TX_DESC_DATA_BW(pdesc, 0);
SET_TX_DESC_TX_SUB_CARRIER(pdesc, 0);
}
SET_TX_DESC_LINIP(pdesc, 0);
SET_TX_DESC_PKT_SIZE(pdesc, (u16) skb->len);
if (sta) {
u8 ampdu_density = sta->ht_cap.ampdu_density;
SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density);
}
if (info->control.hw_key) {
struct ieee80211_key_conf *keyconf =
info->control.hw_key;
switch (keyconf->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
case WLAN_CIPHER_SUITE_TKIP:
SET_TX_DESC_SEC_TYPE(pdesc, 0x1);
break;
case WLAN_CIPHER_SUITE_CCMP:
SET_TX_DESC_SEC_TYPE(pdesc, 0x3);
break;
default:
SET_TX_DESC_SEC_TYPE(pdesc, 0x0);
break;
}
}
SET_TX_DESC_PKT_ID(pdesc, 0);
SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel);
SET_TX_DESC_DATA_RATE_FB_LIMIT(pdesc, 0x1F);
SET_TX_DESC_RTS_RATE_FB_LIMIT(pdesc, 0xF);
SET_TX_DESC_DISABLE_FB(pdesc, 0);
SET_TX_DESC_USE_RATE(pdesc, tcb_desc->use_driver_rate ? 1 : 0);
if (ieee80211_is_data_qos(fc)) {
if (mac->rdg_en) {
RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
"Enable RDG function\n");
SET_TX_DESC_RDG_ENABLE(pdesc, 1);
SET_TX_DESC_HTC(pdesc, 1);
}
}
}
rcu_read_unlock();
SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0));
SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0));
SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) skb->len);
SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping);
if (rtlpriv->dm.useramask) {
SET_TX_DESC_RATE_ID(pdesc, tcb_desc->ratr_index);
SET_TX_DESC_MACID(pdesc, tcb_desc->mac_id);
} else {
SET_TX_DESC_RATE_ID(pdesc, 0xC + tcb_desc->ratr_index);
SET_TX_DESC_MACID(pdesc, tcb_desc->ratr_index);
}
if ((!ieee80211_is_data_qos(fc)) && ppsc->fwctrl_lps) {
SET_TX_DESC_HWSEQ_EN(pdesc, 1);
SET_TX_DESC_PKT_ID(pdesc, 8);
if (!defaultadapter)
SET_TX_DESC_QOS(pdesc, 1);
}
SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1));
if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
is_broadcast_ether_addr(ieee80211_get_DA(hdr))) {
SET_TX_DESC_BMC(pdesc, 1);
}
RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n");
}
void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw,
u8 *pdesc, bool firstseg,
bool lastseg, struct sk_buff *skb)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
u8 fw_queue = QSLT_BEACON;
dma_addr_t mapping = pci_map_single(rtlpci->pdev,
skb->data, skb->len,
PCI_DMA_TODEVICE);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data);
__le16 fc = hdr->frame_control;
if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
"DMA mapping error");
return;
}
CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE);
if (firstseg)
SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE1M);
SET_TX_DESC_SEQ(pdesc, 0);
SET_TX_DESC_LINIP(pdesc, 0);
SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue);
SET_TX_DESC_FIRST_SEG(pdesc, 1);
SET_TX_DESC_LAST_SEG(pdesc, 1);
SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) (skb->len));
SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping);
SET_TX_DESC_RATE_ID(pdesc, 7);
SET_TX_DESC_MACID(pdesc, 0);
SET_TX_DESC_OWN(pdesc, 1);
SET_TX_DESC_PKT_SIZE(pdesc, (u16) (skb->len));
SET_TX_DESC_FIRST_SEG(pdesc, 1);
SET_TX_DESC_LAST_SEG(pdesc, 1);
SET_TX_DESC_OFFSET(pdesc, 0x20);
SET_TX_DESC_USE_RATE(pdesc, 1);
if (!ieee80211_is_data_qos(fc)) {
SET_TX_DESC_HWSEQ_EN(pdesc, 1);
SET_TX_DESC_PKT_ID(pdesc, 8);
}
RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
"H2C Tx Cmd Content", pdesc, TX_DESC_SIZE);
}
void rtl92ce_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
u8 desc_name, u8 *val)
{
if (istx) {
switch (desc_name) {
case HW_DESC_OWN:
wmb();
SET_TX_DESC_OWN(pdesc, 1);
break;
case HW_DESC_TX_NEXTDESC_ADDR:
SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val);
break;
default:
RT_ASSERT(false, "ERR txdesc :%d not process\n",
desc_name);
break;
}
} else {
switch (desc_name) {
case HW_DESC_RXOWN:
wmb();
SET_RX_DESC_OWN(pdesc, 1);
break;
case HW_DESC_RXBUFF_ADDR:
SET_RX_DESC_BUFF_ADDR(pdesc, *(u32 *) val);
break;
case HW_DESC_RXPKT_LEN:
SET_RX_DESC_PKT_LEN(pdesc, *(u32 *) val);
break;
case HW_DESC_RXERO:
SET_RX_DESC_EOR(pdesc, 1);
break;
default:
RT_ASSERT(false, "ERR rxdesc :%d not process\n",
desc_name);
break;
}
}
}
u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
{
u32 ret = 0;
if (istx) {
switch (desc_name) {
case HW_DESC_OWN:
ret = GET_TX_DESC_OWN(p_desc);
break;
case HW_DESC_TXBUFF_ADDR:
ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc);
break;
default:
RT_ASSERT(false, "ERR txdesc :%d not process\n",
desc_name);
break;
}
} else {
struct rx_desc_92c *pdesc = (struct rx_desc_92c *)p_desc;
switch (desc_name) {
case HW_DESC_OWN:
ret = GET_RX_DESC_OWN(pdesc);
break;
case HW_DESC_RXPKT_LEN:
ret = GET_RX_DESC_PKT_LEN(pdesc);
break;
default:
RT_ASSERT(false, "ERR rxdesc :%d not process\n",
desc_name);
break;
}
}
return ret;
}
void rtl92ce_tx_polling(struct ieee80211_hw *hw, u8 hw_queue)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
if (hw_queue == BEACON_QUEUE) {
rtl_write_word(rtlpriv, REG_PCIE_CTRL_REG, BIT(4));
} else {
rtl_write_word(rtlpriv, REG_PCIE_CTRL_REG,
BIT(0) << (hw_queue));
}
}
| [
"jj1232727"
] | jj1232727 |
d941ba5360df7542ae70a0ace835809fb8305352 | 2fceedc14d81d9fcd4ae515522e10feca48ff74a | /4.21数据的序列化/421数据的序列化/resource.h | e9c6621c33b1eecf76868bbbc25c89b459315611 | [] | no_license | Ella666666/66666 | f9758fdf91c8c872475f81854d451e6d117a0616 | f25303cdb52cd5a2b793d7e47e0c2cbf46f76c60 | refs/heads/master | 2022-11-20T00:42:55.974532 | 2020-07-04T01:26:21 | 2020-07-04T01:26:21 | 266,958,955 | 0 | 0 | null | null | null | null | GB18030 | C | false | false | 676 | h | //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 421数据的序列化.rc 使用
//
#define IDD_ABOUTBOX 100
#define IDP_OLE_INIT_FAILED 100
#define IDR_MAINFRAME 128
#define IDR_My421TYPE 130
#define ID_32771 32771
#define ID_Change 32772
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 310
#define _APS_NEXT_COMMAND_VALUE 32773
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 310
#endif
#endif
| [
"2069600381@qq.com"
] | 2069600381@qq.com |
a56184163a4f7a3ab002f273dd3885e77567eef0 | cb8c337a790b62905ad3b30f7891a4dff0ae7b6d | /st-ericsson/multimedia/video/components/jpegenc/common/inc/jpegenc_arm_mpc.h | d0e9e2f0e80bd4386a72e69817e2582375c5ed13 | [] | no_license | CustomROMs/android_vendor | 67a2a096bfaa805d47e7d72b0c7a0d7e4830fa31 | 295e660547846f90ac7ebe42a952e613dbe1b2c3 | refs/heads/master | 2020-04-27T15:01:52.612258 | 2019-03-11T13:26:23 | 2019-03-12T11:23:02 | 174,429,381 | 1 | 0 | null | null | null | null | ISO-8859-1 | C | false | false | 5,815 | h | /******************************************************************************
Copyright (c) 2009-2011, ST-Ericsson SA
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.
3. Neither the name of the ST-Ericsson SA nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.
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 HOLDER 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.
******************************************************************************/
#ifndef __JPEGENC_ARM_MPC_H
#define __JPEGENC_ARM_MPC_H
#include <stdio.h>
#ifdef __JPEGDENC_ARM_NMF //for ARM-NMF
#include <string.h>
//#include <jpegenc/arm_nmf/parser.nmf>
#include "Component.h"
#include "ENS_List.h"
#include <t1xhv_common.idt>
#include <t1xhv_vec.idt>
#include <vfm_common.idt>
//#include <arm_nmf/share/vfm_vec_jpeg.idt>
#include "OMX_Component.h"
#else
#endif
//common includes
#ifdef __JPEGDENC_ARM_NMF //for ARM-NMF
#define convfrom16bitmode(x) x
#define SVP_SHAREDMEM_FROM16(x) x
#define SVP_SHAREDMEM_TO16(x) x
#define SVP_SHAREDMEM_FROM24(x) x
#define SVP_SHAREDMEM_TO24(x) x
#undef METH
#define METH(x) jpegenc_arm_nmf_parser::x
#define COMP(x) jpegenc_arm_nmf_parser::x
#define STATIC_FLAG
#undef SHAREDMEM
#define SHAREDMEM
#define PUT_PRAGMA
#define PRINT_VAR(x)
#define ADD_40 0x0
#define ADD_100 0x0
#define ADD_80 0x0
#undef EXT_BIT
#define EXT_BIT 0
#else //for MPC build
#define ADD_80 0x80
#define ADD_100 0x100
#define ADD_40 0x40
#define COMP(x) x
#define STATIC_FLAG static
#define PUT_PRAGMA #pragma force_dcumode
typedef Buffer_t SHAREDMEM *Buffer_pOSI;
#define Buffer_p Buffer_pOSI
#if !(defined(__svp8500_ed__) || defined(__svp8500_v1__))
#define SVP_SHAREDMEM_FROM16(x) convfrom16bitmode(x)
#define SVP_SHAREDMEM_TO16(x) convto16bitmode(x)
#define SVP_SHAREDMEM_FROM24(x) x
#define SVP_SHAREDMEM_TO24(x) x
//#error "mop selected"
#else
#define SVP_SHAREDMEM_FROM16(x) ((((x)>>16)&0xFFFFul)|(((x)<<16)&0xFFFF0000ul))
#define SVP_SHAREDMEM_TO16(x) ((((x)>>16)&0xFFFFul)|(((x)<<16)&0xFFFF0000ul))
#define SVP_SHAREDMEM_FROM24(x) ((((x)>>24)&0xFFFFFFul)|(((x)<<24)&0xFFFFFF000000ul))
#define SVP_SHAREDMEM_TO24(x) ((((x)>>24)&0xFFFFFFul)|(((x)<<24)&0xFFFFFF000000ul))
#endif //for !(defined(__svp8500_ed__) || defined(__svp8500_v1__))
#endif // for __JPEGDENC_ARM_NMF
#define NB_PORTS 2
typedef struct
{
t_uint16 ready;
t_t1xhv_algo_id algoId;
t_uint32 addr_in_frame_buffer;
t_uint32 addr_out_frame_buffer;
t_uint32 addr_internal_buffer;
t_uint32 addr_header_buffer;
t_uint32 addr_in_bitstream_buffer;
t_uint32 addr_out_bitstream_buffer;
t_uint32 addr_in_parameters;
t_uint32 addr_out_parameters;
t_uint32 addr_in_frame_parameters;
t_uint32 addr_out_frame_parameters;
}
codec_param_type;
typedef enum
{
DDEP_JPEGE_SLICE_TYPE_LAST = 0,
DDEP_JPEGE_SLICE_TYPE_LAST_AND_FIRST,
DDEP_JPEGE_SLICE_TYPE_FIRST,
DDEP_JPEGE_SLICE_TYPE_SUBSEQUENT,
DDEP_JPEGE_SLICE_TYPE_FIRST_SKIPPED
} t_ddep_jpege_slice_type;
typedef struct
{
ts_ddep_buffer_descriptor bbm_desc;
ts_ddep_buffer_descriptor s_debug_buffer_desc;
} ts_ddep_sec_jpeg_ddep_desc;
typedef struct {
ts_t1xhv_bitstream_buf_link s_ddep_bitstream_buf_link; /* keep it first */
t_uint32 s_ddep_buffer_p;
#ifdef __JPEGDENC_ARM_NMF
t_uint16 reserved[16-(sizeof(ts_t1xhv_bitstream_buf_link)+sizeof(OMX_BUFFERHEADERTYPE))%16]; /*::CP t_uint16 -->> t_uint24 ???*/
#else
t_uint16 reserved[16-(sizeof(ts_t1xhv_bitstream_buf_link)+sizeof(Buffer_t))%16]; /*::CP t_uint16 -->> t_uint24 ???*/
#endif
} ts_ddep_bitstream_buf_link_and_header;
//static void common_ReleaseBuffer(void *,t_uint32 port_idx,Buffer_p buf);
//static void common_release_resources(void *);
//static t_uint16 common_buffer_available_atinput(void *);
//static t_uint16 common_buffer_available_atoutput(void *);
//static void common_linkin_loop(void *);
//static void common_update_link(void *);
//static void common_create_link(void *);
//static void common_program_link(void *);
//static void common_setNeeds(void *);
//static void common_download_parameters(void *);
//static void common_setParameter(void *);
#endif // __JPEGENC_ARM_MPC_H
| [
"xiangxin19960319@gmail.com"
] | xiangxin19960319@gmail.com |
9774042dcf96fb408312fbf00839f9e2b796985f | b6d51f0108ee472e9a7ec1f6bfc9f6459f9789fd | /source/systimer.c | 38de3b69dd5c37d86f86e78cc391e43bd0655d4b | [] | no_license | xsmart/sdk | 1fd5476be8163f178e418053aa40eea5b7eba0dc | cad1ace52dba141feee1950f82df1af2337181a4 | refs/heads/master | 2021-01-21T18:58:50.926447 | 2014-11-25T06:27:29 | 2014-11-25T06:27:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 5,377 | c | #include "systimer.h"
// Linux link with -lrt
#if defined(OS_WINDOWS)
#include <Windows.h>
#pragma comment(lib, "Winmm.lib")
#else
#include <signal.h>
#include <time.h>
#endif
#include <assert.h>
#include <memory.h>
#include <stdlib.h>
#include <errno.h>
typedef struct _timer_context_t
{
systimer_proc callback;
void* cbparam;
#if defined(OS_WINDOWS)
UINT timerId;
unsigned int period;
unsigned int count;
LONG locked;
#elif defined(OS_WINDOWS_ASYNC)
HANDLE timerId;
#elif defined(OS_LINUX)
timer_t timerId;
int ontshot;
#endif
} timer_context_t;
#if defined(OS_WINDOWS)
struct
{
TIMECAPS tc;
thread_pool_t pool;
} g_ctx;
#define TIMER_PERIOD 1000
#endif
#if defined(OS_WINDOWS)
static void timer_thread_worker(void *param)
{
timer_context_t* ctx;
ctx = (timer_context_t*)param;
if(ctx->period > g_ctx.tc.wPeriodMax)
{
if(ctx->count == ctx->period / TIMER_PERIOD)
ctx->callback((systimer_t)ctx, ctx->cbparam);
ctx->count = (ctx->count + 1) % (ctx->period / TIMER_PERIOD + 1);
}
else
{
ctx->callback((systimer_t)ctx, ctx->cbparam);
}
InterlockedDecrement(&ctx->locked);
}
static void CALLBACK timer_schd_worker(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
{
timer_context_t* ctx;
ctx = (timer_context_t*)dwUser;
if(1 != InterlockedIncrement(&ctx->locked))
{
InterlockedDecrement(&ctx->locked);
}
else
{
// one timer only can be call in one thread
thread_pool_push(g_ctx.pool, timer_thread_worker, ctx);
}
}
#elif defined(OS_LINUX)
static void timer_schd_worker(union sigval v)
{
timer_context_t* ctx;
ctx = (timer_context_t*)v.sival_ptr;
ctx->callback((systimer_t)ctx, ctx->cbparam);
}
#else
static int timer_schd_worker(void *param)
{
}
#endif
int systimer_init(thread_pool_t pool)
{
#if defined(OS_WINDOWS)
timeGetDevCaps(&g_ctx.tc, sizeof(TIMECAPS));
g_ctx.pool = pool;
#endif
return 0;
}
int systimer_clean(void)
{
return 0;
}
#if defined(OS_WINDOWS)
static int systimer_create(systimer_t* id, unsigned int period, int oneshot, systimer_proc callback, void* cbparam)
{
UINT fuEvent;
timer_context_t* ctx;
if(oneshot && g_ctx.tc.wPeriodMin > period && period > g_ctx.tc.wPeriodMax)
return -EINVAL;
ctx = (timer_context_t*)malloc(sizeof(timer_context_t));
if(!ctx)
return -ENOMEM;
memset(ctx, 0, sizeof(timer_context_t));
ctx->callback = callback;
ctx->cbparam = cbparam;
ctx->period = period;
ctx->count = 0;
// check period value
period = (period > g_ctx.tc.wPeriodMax) ? TIMER_PERIOD : period;
fuEvent = (oneshot?TIME_ONESHOT:TIME_PERIODIC)|TIME_CALLBACK_FUNCTION;
ctx->timerId = timeSetEvent(period, 10, timer_schd_worker, (DWORD_PTR)ctx, fuEvent);
if(0 == ctx->timerId)
{
free(ctx);
return -EINVAL;
}
*id = (systimer_t)ctx;
return 0;
}
#elif defined(OS_LINUX)
static int systimer_create(systimer_t* id, unsigned int period, int oneshot, systimer_proc callback, void* cbparam)
{
struct sigevent sev;
struct itimerspec tv;
timer_context_t* ctx;
ctx = (timer_context_t*)malloc(sizeof(timer_context_t));
if(!ctx)
return -ENOMEM;;
memset(ctx, 0, sizeof(timer_context_t));
ctx->callback = callback;
ctx->cbparam = cbparam;
memset(&sev, 0, sizeof(sev));
sev.sigev_notify = SIGEV_THREAD;
sev.sigev_value.sival_ptr = ctx;
sev.sigev_notify_function = timer_schd_worker;
if(0 != timer_create(CLOCK_MONOTONIC, &sev, &ctx->timerId))
{
free(ctx);
return -errno;
}
tv.it_interval.tv_sec = period / 1000;
tv.it_interval.tv_nsec = (period % 1000) * 1000000; // 10(-9)second
tv.it_value.tv_sec = tv.it_interval.tv_sec;
tv.it_value.tv_nsec = tv.it_interval.tv_nsec;
if(0 != timer_settime(ctx->timerId, 0, &tv, NULL))
{
timer_delete(ctx->timerId);
free(ctx);
return -errno;
}
*id = (systimer_t)ctx;
return 0;
}
#elif defined(OS_WINDOWS_ASYNC)
static int systimer_create(systimer_t* id, unsigned int period, int oneshot, systimer_proc callback, void* cbparam)
{
LARGE_INTEGER tv;
timer_context_t* ctx;
ctx = (timer_context_t*)malloc(sizeof(timer_context_t));
if(!ctx)
return -ENOMEM;
memset(ctx, 0, sizeof(timer_context_t));
ctx->callback = callback;
ctx->cbparam = cbparam;
ctx->timerId = CreateWaitableTimer(NULL, FALSE, NULL);
if(0 == ctx->timerId)
{
free(ctx);
return -(int)GetLastError();
}
tv.QuadPart = -10000L * period; // in 100 nanosecond intervals
if(!SetWaitableTimer(ctx->timerId, &tv, oneshot?0:period, timer_schd_worker, ctx, FALSE))
{
CloseHandle(ctx->timerId);
free(ctx);
return -(int)GetLastError();
}
*id = (systimer_t)ctx;
return 0;
}
#else
static int systimer_create(systimer_t* id, int period, systimer_proc callback, void* cbparam)
{
ERROR: dont implemention
}
#endif
int systimer_oneshot(systimer_t *id, unsigned int period, systimer_proc callback, void* cbparam)
{
return systimer_create(id, period, 1, callback, cbparam);
}
int systimer_start(systimer_t* id, unsigned int period, systimer_proc callback, void* cbparam)
{
return systimer_create(id, period, 0, callback, cbparam);
}
int systimer_stop(systimer_t id)
{
timer_context_t* ctx;
if(!id) return -EINVAL;
ctx = (timer_context_t*)id;
#if defined(OS_WINDOWS)
timeKillEvent(ctx->timerId);
#elif defined(OS_LINUX)
timer_delete(ctx->timerId);
#elif defined(OS_WINDOWS_ASYNC)
CloseHandle(ctx->timerId);
#else
ERROR: dont implemention
#endif
free(ctx); // take care call-back function
return 0;
}
| [
"iguest@sogou.com"
] | iguest@sogou.com |
0b2cfc17e83c6648430f20a0ffc388fb1692379f | 092a97511c1b08dc960ae2d721c1969d361508d3 | /src/swipl-7.7.10/packages/sgml/xsd.c | d9cc2b2b3f40387be49bc12c896488953f7702f1 | [
"BSD-2-Clause"
] | permissive | 42n4/rolog | 2da1a5f0f8ca4e3ab3e7e6123166e39f8a188bea | b836220551c20c265cb1c55e02c2e561459aa508 | refs/heads/master | 2021-04-27T09:06:47.945084 | 2018-02-23T02:00:48 | 2018-02-23T02:00:48 | 122,507,761 | 3 | 0 | null | 2018-02-22T16:55:41 | 2018-02-22T16:55:40 | null | UTF-8 | C | false | false | 21,215 | c | /* Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@vu.nl
WWW: http://www.swi-prolog.org
Copyright (c) 2016, VU University Amsterdam
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.
*/
#include <SWI-Prolog.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define URL_xsd "http://www.w3.org/2001/XMLSchema#"
#define issign(c) (c == '-' || c == '+')
#define isdigit(c) (c >= '0' && c <= '9')
#define isexp(c) (c == 'e' || c == 'E')
#define isdot(c) (c == '.')
/* BUG: goes wrong if locale is switched at runtime. But, doing
this dynamically is a more than 100% overhead on xsd_number_string/2
and changing locale after process initialization is uncommon and
a bad idea anyway.
*/
static int
decimal_dot(void)
{ static int ddot = '\0';
if ( ddot )
return ddot;
char buf[10];
sprintf(buf, "%f", 1.0);
ddot = buf[1];
return ddot;
}
static foreign_t
xsd_number_string(term_t number, term_t string)
{ char *in;
size_t len;
if ( PL_get_nchars(string, &len, &in, CVT_ATOM|CVT_STRING|CVT_LIST) )
{ char *s = in;
if ( strlen(s) == len ) /* no 0-characters */
{ int isfloat = FALSE;
int hasdot=FALSE;
if ( strcmp(s, "NaN") != 0 )
{ int decl = 0, dect = 0;
if ( issign(*s) ) s++; /* [+-]? */
if ( strcmp(s, "INF") == 0 )
{ isfloat = TRUE;
goto ok;
}
while(isdigit(*s)) decl++, s++; /* [0-9]* */
if ( isdot(*s) ) /* [.]? */
{ s++;
isfloat = TRUE;
hasdot = TRUE;
while(isdigit(*s)) dect++, s++; /* [0-9]* */
}
if ( decl+dect == 0 )
goto syntax_error;
if ( isexp(*s) )
{ int exp = 0;
s++;
isfloat = TRUE;
if ( issign(*s) ) s++; /* [+-]? */
while(isdigit(*s)) exp++, s++; /* [0-9]+ */
if ( exp == 0 )
goto syntax_error;
}
if ( *s )
goto syntax_error;
} else
{ isfloat = TRUE;
}
ok:
if ( isfloat )
{ int dot;
int rc;
char *end;
if ( hasdot && (dot=decimal_dot()) != '.' )
{ char fast[64];
char *fs = len < sizeof(fast) ? fast : malloc(len+1);
char *o;
if ( !fs )
return PL_resource_error("memory");
for(s=in,o=fs; *s; s++,o++)
{ if ( (*o=*s) == '.' )
*o = dot;
}
*o = '\0';
rc = PL_unify_float(number, strtod(fs, &end));
if ( fs != fast )
free(fs);
} else
{ rc = PL_unify_float(number, strtod(in, &end));
}
assert(*end == '\0');
return rc;
} else
{ term_t n = PL_new_term_ref();
return ( PL_chars_to_term(in, n) &&
PL_unify(number, n)
);
}
} else
{
syntax_error:
return PL_syntax_error("xsd_number", NULL);
}
} else if ( PL_get_nchars(number, &len, &in, CVT_NUMBER) )
{ if ( PL_is_float(number) )
{ char buf[32];
char *s, *e;
int exp_shift = 0;
if ( len > 3 && strcmp(&in[len-3], "Inf") == 0 )
return PL_unify_chars(string, PL_STRING, (size_t)-1,
in[0] == '-' ? "-INF" : "INF");
if ( len > 3 && strcmp(&in[len-3], "NaN") == 0 )
return PL_unify_chars(string, PL_STRING, (size_t)-1, "NaN");
assert(len < 32);
strcpy(buf, in);
s = buf;
if ( s[0] == '-' ) s++;
if ( s[0] == '0' )
{ assert(s[1] == '.');
s += 2;
if ( *s == '0' && s[1] )
{ for(e=s; *e=='0'; e++) exp_shift--;
memmove(&s[0], &s[-exp_shift], strlen(&s[-exp_shift])+1);
}
} else
{ char *dp = strchr(s, '.');
if ( dp-s > 1 )
{ exp_shift = dp-s-1;
memmove(&s[2], &s[1], exp_shift);
s[1] = '.';
}
}
if ( (e=strchr(buf, 'e')) )
{ *e++ = 'E';
if ( e[0] == '+' )
memmove(&e[0], &e[1], strlen(&e[1])+1);
if ( exp_shift )
sprintf(e, "%d", atoi(e)+exp_shift);
} else
{ e = &buf[strlen(buf)];
if ( exp_shift > 0 )
{ while(e[-1] == '0' && e[-2] != '.')
e--;
}
sprintf(e, "E%d", exp_shift);
}
return PL_unify_chars(string, PL_STRING, (size_t)-1, buf);
} else
{ return PL_unify_chars(string, PL_STRING, len, in);
}
} else if ( !PL_is_variable(number) )
{ return PL_type_error("number", number);
} else
{ return PL_type_error("text", string);
}
}
/*******************************
* DATE AND TIME *
*******************************/
static functor_t FUNCTOR_date3;
static functor_t FUNCTOR_time3;
static functor_t FUNCTOR_date_time6;
static functor_t FUNCTOR_date_time7;
static functor_t FUNCTOR_month_day2;
static functor_t FUNCTOR_year_month2;
static functor_t FUNCTOR_error2;
static functor_t FUNCTOR_syntax_error1;
static functor_t FUNCTOR_domain_error2;
static functor_t FUNCTOR_xsd_time1;
static atom_t URL_date;
static atom_t URL_dateTime;
static atom_t URL_gDay;
static atom_t URL_gMonth;
static atom_t URL_gMonthDay;
static atom_t URL_gYear;
static atom_t URL_gYearMonth;
static atom_t URL_time;
typedef struct
{ int hour;
int minute;
int sec_is_float;
union
{ int i;
double f;
} second;
} time;
static int
get_int_arg(term_t t, int n, int *ip)
{ term_t a = PL_new_term_ref();
_PL_get_arg(n, t, a);
return PL_get_integer_ex(a, ip);
}
static int
get_int_args(term_t t, int n, int *av)
{ term_t a = PL_new_term_ref();
int i;
for(i=0; i<n; i++)
{ _PL_get_arg(i+1, t, a);
if ( !PL_get_integer_ex(a, &av[i]) )
return FALSE;
}
return TRUE;
}
static int
get_time_args(term_t t, int offset, time *tm)
{ term_t a = PL_new_term_ref();
_PL_get_arg(offset+1, t, a);
if ( !PL_get_integer_ex(a, &tm->hour) )
return FALSE;
_PL_get_arg(offset+2, t, a);
if ( !PL_get_integer_ex(a, &tm->minute) )
return FALSE;
_PL_get_arg(offset+3, t, a);
if ( PL_get_integer(a, &tm->second.i) )
{ tm->sec_is_float = FALSE;
} else if ( PL_get_float_ex(a, &tm->second.f) )
{ tm->sec_is_float = TRUE;
} else
return FALSE;
return TRUE;
}
typedef enum
{ END,
INT2,
INTYEAR,
DECIMAL,
MINUS,
PLUS,
COLON,
TT,
TZ
} time_field;
static int
parse_date_parts(const char *in, int *av, size_t avlen)
{ size_t ca = 0;
#define ADDINT(i) \
do { if ( ca < avlen ) { av[ca++] = (i); } else { return 1; } } while(0)
#define DV(i) (in[i]-'0')
while(*in)
{ if ( isdigit(in[0]) &&
isdigit(in[1]) )
{ if ( isdigit(in[2]) &&
isdigit(in[3]) )
{ int v = DV(0)*1000+DV(1)*100+DV(2)*10+DV(3);
int n = 4;
for(n=4; isdigit(in[n]); n++)
{ v = v*10+DV(n);
}
ADDINT(INTYEAR);
ADDINT(v);
in += n;
} else
{ ADDINT(INT2);
ADDINT(DV(0)*10+DV(1));
in += 2;
}
} else
{ switch(in[0])
{ case '-': ADDINT(MINUS); in++; break;
case '+': ADDINT(PLUS); in++; break;
case ':': ADDINT(COLON); in++; break;
case 'T': ADDINT(TT); in++; break;
case 'Z': ADDINT(TZ); in++; break;
case '.': ADDINT(DECIMAL); in++;
{ int v = 0;
if ( !isdigit(in[0]) )
return 2;
while(isdigit(in[0]))
{ v = v*10+DV(0);
in++;
}
ADDINT(v);
break;
}
default:
return 2;
}
}
}
ADDINT(END);
#undef DV
#undef ADDINT
return 0;
}
static int
int_domain(const char *domain, int i)
{ term_t t = PL_new_term_ref();
return ( PL_put_integer(t, i) && PL_domain_error(domain, t) );
}
static int
float_domain(const char *domain, double f)
{ term_t t = PL_new_term_ref();
return ( PL_put_float(t, f) && PL_domain_error(domain, t) );
}
static int
valid_year(int i)
{ if ( i != 0 )
return TRUE;
return int_domain("year", i);
}
static int
valid_month(int i)
{ if ( i >= 1 && i <= 12 )
return TRUE;
return int_domain("month", i);
}
static int
valid_day(int i)
{ if ( i >= 1 && i <= 31 )
return TRUE;
return int_domain("day", i);
}
static int
valid_hour(int i)
{ if ( i >= 0 && i <= 23 )
return TRUE;
return int_domain("hour", i);
}
static int
valid_minute(int i)
{ if ( i >= 0 && i <= 59 )
return TRUE;
return int_domain("minute", i);
}
static int
valid_second(int i)
{ if ( i >= 0 && i <= 59 )
return TRUE;
return int_domain("second", i);
}
static int
valid_second_f(double f)
{ if ( f >= 0.0 && f < 60.0 )
return TRUE;
return float_domain("second", f);
}
static int
valid_date(int v[3])
{ return (valid_year(v[0]) && valid_month(v[1]) && valid_day(v[2]));
}
static int
valid_time(const time *t)
{ if ( t->hour == 24 && t->minute == 0 &&
(t->sec_is_float ? t->second.f == 0.0 : t->second.i == 0) )
return TRUE; /* 24:00:00[.0+] */
if ( valid_hour(t->hour) &&
valid_minute(t->minute) )
{ if ( t->sec_is_float )
return valid_second_f(t->second.f);
else
return valid_second(t->second.i);
}
return FALSE;
}
static int
valid_tz(int hoff, int moff)
{ if ( hoff >= 0 && hoff <= 13 )
return valid_minute(moff);
else if ( hoff == 14 && moff == 0 )
return TRUE;
else
return int_domain("tz_hour", hoff);
}
static int
valid_tzoffset(int sec)
{ if ( sec < -12*3600 || sec > 12*3600 )
return int_domain("tz_offset", sec);
return TRUE;
}
static int
is_time_seq(const int av[], time *t)
{ if ( av[0] == INT2 && av[2] == COLON &&
av[3] == INT2 && av[5] == COLON &&
av[6] == INT2 )
{ t->hour = av[1];
t->minute = av[4];
if ( av[8] == DECIMAL )
{ int v, div = 1;
t->sec_is_float = TRUE;
for(v=av[9]; v; v /= 10)
div *= 10;
t->second.f = (double)av[7] + (double)av[9]/(double)div;
return 10;
} else
{ t->sec_is_float = FALSE;
t->second.i = av[7];
return 8;
}
}
return 0;
}
static char *
time_sec_chars(time *t, char *buf)
{ if ( !t->sec_is_float )
{ sprintf(buf, "%02d", t->second.i);
return buf;
} else
{ char *s, *e;
buf[0] = '0';
sprintf(&buf[1], "%f", t->second.f);
if ( !isdigit(buf[2]) )
{ buf[2] = '.';
s = buf;
} else
{ assert(!isdigit(buf[3]));
buf[3] = '.';
s = buf+1;
}
e = s+strlen(s);
while(e[-1] == '0' && e[-2] != '.' )
e--;
e[0] = 0;
return s;
}
}
/** xsd_time_string(+Term, ?Type, -String) is det.
xsd_time_string(-Term, ?Type, +String) is det.
*/
static int
is_time_url(atom_t url)
{ return ( url == URL_date ||
url == URL_dateTime ||
url == URL_gDay ||
url == URL_gMonth ||
url == URL_gMonthDay ||
url == URL_gYear ||
url == URL_gYearMonth ||
url == URL_time );
}
static int
maybe_invalid_time_url(term_t type)
{ atom_t url;
if ( PL_get_atom_ex(type, &url) )
{ if ( is_time_url(url) )
return FALSE;
return PL_domain_error("xsd_time_url", type);
}
return FALSE;
}
static int
mkyear(int v, int sign)
{ if ( sign == 1 )
{ if ( v == 0 )
return -1;
return v;
}
return -(v+1);
}
static int
unify_parsed_type(term_t t, atom_t type)
{ if ( PL_unify_atom(t, type) )
{ return TRUE;
} else
{ if ( PL_is_atom(t) )
{ term_t ex;
return ( (ex=PL_new_term_ref()) &&
PL_unify_term(ex, PL_FUNCTOR, FUNCTOR_error2,
PL_FUNCTOR, FUNCTOR_syntax_error1,
PL_FUNCTOR, FUNCTOR_xsd_time1,
PL_ATOM, type,
PL_VARIABLE) &&
PL_raise_exception(ex)
);
}
return FALSE;
}
}
static int
incompatible_time_term(term_t term, atom_t type_atom)
{ term_t ex;
return ( (ex=PL_new_term_ref()) &&
PL_unify_term(ex, PL_FUNCTOR, FUNCTOR_error2,
PL_FUNCTOR, FUNCTOR_domain_error2,
PL_FUNCTOR, FUNCTOR_xsd_time1,
PL_ATOM, type_atom,
PL_TERM, term,
PL_VARIABLE) &&
PL_raise_exception(ex)
);
}
static int
unify_prolog_type(term_t term, term_t type_term, atom_t type_atom)
{ if ( PL_unify_atom(type_term, type_atom) )
{ return TRUE;
} else
{ if ( PL_is_atom(type_term) )
incompatible_time_term(term, type_atom);
return FALSE;
}
}
static foreign_t
xsd_time_string(term_t term, term_t type, term_t string)
{ if ( PL_is_variable(string) ) /* +, ?, - */
{ char buf[100], b2[20];
atom_t at = 0;
int v;
if ( PL_is_functor(term, FUNCTOR_date3) ) /* date(Y,M,D) */
{ int v[3];
char *sign = "";
if ( !get_int_args(term, 3, v) || !valid_date(v) )
return FALSE;
at = URL_date;
if ( v[0] < 0 )
{ sign = "-";
v[0] = -v[0];
}
sprintf(buf, "%s%04d-%02d-%02d", sign, v[0],v[1],v[2]);
} else if ( PL_is_functor(term, FUNCTOR_date_time6) )
{ int v[3];
time t;
char *sign = "";
if ( !get_int_args(term, 3, v) ||
!get_time_args(term, 3, &t) ||
!valid_date(v) || !valid_time(&t) )
return FALSE;
at = URL_dateTime;
if ( v[0] < 0 )
{ sign = "-";
v[0] = -v[0];
}
sprintf(buf, "%s%04d-%02d-%02dT%02d:%02d:%s",
sign, v[0], v[1], v[2], t.hour, t.minute, time_sec_chars(&t, b2));
} else if ( PL_is_functor(term, FUNCTOR_date_time7) )
{ int v[3], tz;
time t;
char *sign = "";
if ( !get_int_args(term, 3, v) ||
!get_time_args(term, 3, &t) ||
!get_int_arg(term, 7, &tz) ||
!valid_date(v) || !valid_time(&t) ||
!valid_tzoffset(tz) )
return FALSE;
at = URL_dateTime;
if ( v[0] < 0 )
{ sign = "-";
v[0] = -v[0];
}
sprintf(buf, "%s%04d-%02d-%02dT%02d:%02d:%s",
sign, v[0], v[1], v[2], t.hour, t.minute, time_sec_chars(&t, b2));
if ( tz == 0 )
{ strcat(buf, "Z");
} else
{ char sign = tz < 0 ? '-' : '+';
int tza = tz < 0 ? -tz : tz;
char *out = buf+strlen(buf);
sprintf(out, "%c%02d:%02d", sign, tza/3600, (tza % 3600)/60);
}
} else if ( PL_is_functor(term, FUNCTOR_time3) )
{ time t;
if ( !get_time_args(term, 0, &t) || !valid_time(&t) )
return FALSE;
at = URL_time;
sprintf(buf, "%02d:%02d:%s",
t.hour, t.minute, time_sec_chars(&t, b2));
} else if ( PL_is_functor(term, FUNCTOR_month_day2) )
{ int v[2];
if ( !get_int_args(term, 2, v) )
return FALSE;
at = URL_gMonthDay;
sprintf(buf, "%02d-%02d",
v[0], v[1]);
} else if ( PL_is_functor(term, FUNCTOR_year_month2) )
{ int v[2];
char *sign = "";
if ( !get_int_args(term, 2, v) )
return FALSE;
if ( v[0] < 0 )
{ sign = "-";
v[0] = -v[0];
}
at = URL_gYearMonth;
sprintf(buf, "%s%04d-%02d", sign, v[0], v[1]);
} else if ( PL_get_integer(term, &v) )
{ atom_t url;
if ( !PL_get_atom_ex(type, &url) )
return FALSE;
if ( url == URL_gDay )
{ if ( !valid_day(v) )
return FALSE;
sprintf(buf, "%02d", v);
} else if ( url == URL_gMonth )
{ if ( !valid_month(v) )
return FALSE;
sprintf(buf, "%02d", v);
} else if ( url == URL_gYear )
{ char *sign = "";
if ( !valid_year(v) )
return FALSE;
if ( v == -1 )
{ v = 0;
} else if ( v < 0 )
{ sign = "-";
v = -v - 1;
}
sprintf(buf, "%s%04d", sign, v);
} else if ( is_time_url(url) )
{ return incompatible_time_term(term, url);
} else
return PL_domain_error("xsd_time_url", type);
} else
{ return PL_domain_error("xsd_time", term);
}
if ( at && !unify_prolog_type(term, type, at) )
return FALSE;
return PL_unify_chars(string, PL_STRING, (size_t)-1, buf);
} else /* -, ?, + */
{ char *in;
size_t len;
int avb[30];
int *av = avb;
time t;
int tlen;
int yearsign = 1;
if ( !PL_get_nchars(string, &len, &in,
CVT_ATOM|CVT_STRING|CVT_LIST|CVT_EXCEPTION) )
return FALSE;
if ( parse_date_parts(in, avb, sizeof(avb)/sizeof(*avb)) )
return PL_syntax_error("xsd_time", NULL);
if ( av[0] == MINUS )
{ av++;
yearsign = -1;
}
if ( av[0] == INTYEAR && av[2] == MINUS &&
av[3] == INT2 && av[5] == MINUS &&
av[6] == INT2 ) /* YYYY-MM-DD */
{ int v[3] = {mkyear(av[1],yearsign),av[4],av[7]};
if ( !valid_date(v) )
return FALSE;
if ( av[8] == END )
{ return (unify_parsed_type(type, URL_date) &&
PL_unify_term(term, PL_FUNCTOR, FUNCTOR_date3,
PL_INT, mkyear(av[1],yearsign),
PL_INT, av[4], PL_INT, av[7]) );
} else if ( av[8] == TT &&
(tlen=is_time_seq(av+9, &t)) ) /* THH:MM:SS[.DDD] */
{ int at = 9+tlen;
term_t sec = PL_new_term_ref();
if ( !valid_time(&t) )
return FALSE;
if ( !(t.sec_is_float ? PL_put_float(sec, t.second.f)
: PL_put_integer(sec, t.second.i)) )
return FALSE;
if ( av[at] == END )
return (unify_parsed_type(type, URL_dateTime) &&
PL_unify_term(term, PL_FUNCTOR, FUNCTOR_date_time6,
PL_INT, mkyear(av[1],yearsign),
PL_INT, av[ 4], PL_INT, av[ 7],
PL_INT, t.hour, PL_INT, t.minute, PL_TERM, sec));
if ( av[at] == TZ && av[at+1] == END )
return (unify_parsed_type(type, URL_dateTime) &&
PL_unify_term(term, PL_FUNCTOR, FUNCTOR_date_time7,
PL_INT, mkyear(av[1],yearsign),
PL_INT, av[ 4], PL_INT, av[ 7],
PL_INT, t.hour, PL_INT, t.minute, PL_TERM, sec,
PL_INT, 0));
if ( (av[at] == MINUS || av[at] == PLUS) &&
av[at+1] == INT2 && av[at+3] == COLON &&
av[at+4] == INT2 && av[at+6] == END )
{ int tz = av[at+2]*3600 + av[at+5]*60;
if ( av[at] == MINUS ) tz = -tz;
if ( !valid_tz(av[at+2], av[at+5]) )
return FALSE;
return (unify_parsed_type(type, URL_dateTime) &&
PL_unify_term(term, PL_FUNCTOR, FUNCTOR_date_time7,
PL_INT, mkyear(av[1],yearsign),
PL_INT, av[ 4], PL_INT, av[ 7],
PL_INT, t.hour, PL_INT, t.minute, PL_TERM, sec,
PL_INT, tz));
}
}
}
if ( (tlen=is_time_seq(av, &t)) && av[tlen] == END )
{ term_t sec = PL_new_term_ref();
if ( !valid_time(&t) )
return FALSE;
if ( yearsign == -1 )
return PL_syntax_error("xsd_time", NULL);
if ( !(t.sec_is_float ? PL_put_float(sec, t.second.f)
: PL_put_integer(sec, t.second.i)) )
return FALSE;
return (valid_time(&t) &&
unify_parsed_type(type, URL_time) &&
PL_unify_term(term, PL_FUNCTOR, FUNCTOR_time3,
PL_INT, t.hour, PL_INT, t.minute, PL_TERM, sec) );
}
if ( av[0] == INT2 && av[2] == MINUS && av[3] == INT2 && av[5] == END )
{ if ( yearsign == -1 )
return PL_syntax_error("xsd_time", NULL);
return (valid_month(av[1]) && valid_day(av[4]) &&
unify_parsed_type(type, URL_gMonthDay) &&
PL_unify_term(term, PL_FUNCTOR, FUNCTOR_month_day2,
PL_INT, av[1], PL_INT, av[4]) );
}
if ( av[0] == INTYEAR && av[2] == MINUS && av[3] == INT2 && av[5] == END )
{ return (valid_year(mkyear(av[1],yearsign)) && valid_month(av[4]) &&
unify_parsed_type(type, URL_gYearMonth) &&
PL_unify_term(term, PL_FUNCTOR, FUNCTOR_year_month2,
PL_INT, mkyear(av[1],yearsign), PL_INT, av[4]) );
}
if ( av[0] == INTYEAR && av[2] == END )
{ return (valid_year(mkyear(av[1],yearsign)) &&
unify_parsed_type(type, URL_gYear) &&
PL_unify_integer(term, mkyear(av[1],yearsign)));
}
if ( av[0] == INT2 && av[2] == END )
{ atom_t url;
if ( yearsign == -1 )
return PL_syntax_error("xsd_time", NULL);
if ( !PL_get_atom_ex(type, &url) )
return FALSE;
if ( url == URL_gDay )
return valid_day(av[1]) && PL_unify_integer(term, av[1]);
if ( url == URL_gMonth )
return valid_month(av[1]) && PL_unify_integer(term, av[1]);
return maybe_invalid_time_url(type);
}
return PL_syntax_error("xsd_time", NULL);
}
}
#define MKFUNCTOR(n, a) \
FUNCTOR_ ## n ## a = PL_new_functor(PL_new_atom(#n), a)
#define MKURL(n) \
URL_ ## n = PL_new_atom(URL_xsd #n);
install_t
install_xsd(void)
{ MKFUNCTOR(date, 3);
MKFUNCTOR(date_time, 6);
MKFUNCTOR(date_time, 7);
MKFUNCTOR(time, 3);
MKFUNCTOR(month_day, 2);
MKFUNCTOR(year_month, 2);
MKFUNCTOR(error, 2);
MKFUNCTOR(syntax_error, 1);
MKFUNCTOR(domain_error, 2);
MKFUNCTOR(xsd_time, 1);
MKURL(date);
MKURL(dateTime);
MKURL(gDay);
MKURL(gMonth);
MKURL(gMonthDay);
MKURL(gYear);
MKURL(gYearMonth);
MKURL(time);
PL_register_foreign("xsd_number_string", 2, xsd_number_string, 0);
PL_register_foreign("xsd_time_string", 3, xsd_time_string, 0);
}
| [
"Matthias.Gondan@psy.ku.dk"
] | Matthias.Gondan@psy.ku.dk |
570c414cd91917d493401f194fd2301821f6b9dd | d4de686f291c663bfe0c4c6246261990ab22256f | /src/pages/audiobooks/audiobook-view.h | fe5cee4b33db992803e0e5c845a4d4c1d2e34e49 | [
"Apache-2.0"
] | permissive | strogo/koto | f2a2f018d832dacfb79df574255a3ffaf2efadaa | 62f288384932c2b7faa099d456162af37edef1a8 | refs/heads/master | 2023-07-07T21:47:27.013094 | 2021-08-17T16:27:33 | 2021-08-17T16:27:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,573 | h | /* audiobook-view.h
*
* Copyright 2021 Joshua Strobl
*
* 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.
*/
#pragma once
#include <glib-2.0/glib-object.h>
#include <gtk-4.0/gtk/gtk.h>
#include "../../indexer/structs.h"
G_BEGIN_DECLS
#define KOTO_TYPE_AUDIOBOOK_VIEW (koto_audiobook_view_get_type())
G_DECLARE_FINAL_TYPE(KotoAudiobookView, koto_audiobook_view, KOTO, AUDIOBOOK_VIEW, GtkBox);
#define KOTO_IS_AUDIOBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), KOTO_TYPE_AUDIOBOOK_VIEW))
void koto_audiobook_view_set_album(
KotoAudiobookView * self,
KotoAlbum * album
);
GtkWidget * koto_audiobook_view_create_track_item(
gpointer item,
gpointer user_data
);
void koto_audiobook_view_handle_play_clicked(
GtkButton * button,
gpointer user_data
);
void koto_audiobook_view_handle_playlist_updated(
KotoPlaylist * playlist,
gpointer user_data
);
void koto_audiobook_view_update_side_info(KotoAudiobookView * self);
void koto_audiobook_view_destroy_associated_user_data(gpointer user_data);
KotoAudiobookView * koto_audiobook_view_new();
G_END_DECLS | [
"joshua@streambits.io"
] | joshua@streambits.io |
9fc7c04b9effcb7b4fbd468edef8658662b33835 | 690d99023e33928fbf40158822c59075533eaf44 | /pyapprox/cython/adaptive_sparse_grid.c | 9164b196ffbdda29818a95b7d1d12405b3527031 | [
"MIT"
] | permissive | allevin/pyapprox | 321a16d1831a6f9abdc9ece632556c29425eb5aa | 2351b1818f3b72554bcb6cc72e994c283c9eb752 | refs/heads/master | 2022-11-20T14:45:02.519387 | 2020-07-27T03:23:52 | 2020-07-27T03:23:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | true | 884,278 | c | /* Generated by Cython 0.29.18 */
/* BEGIN: Cython Metadata
{
"distutils": {
"name": "pyapprox.cython.adaptive_sparse_grid",
"sources": [
"pyapprox/cython/adaptive_sparse_grid.pyx"
]
},
"module_name": "pyapprox.cython.adaptive_sparse_grid"
}
END: Cython Metadata */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
#error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_18"
#define CYTHON_HEX_VERSION 0x001D12F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
#ifndef __stdcall
#define __stdcall
#endif
#ifndef __cdecl
#define __cdecl
#endif
#ifndef __fastcall
#define __fastcall
#endif
#endif
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
#define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
#if PY_VERSION_HEX >= 0x02070000
#define HAVE_LONG_LONG
#endif
#endif
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
#define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 0
#undef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 0
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#if PY_VERSION_HEX < 0x03050000
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#undef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#undef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 1
#undef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 0
#undef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 0
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#undef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 0
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#undef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 0
#undef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 0
#undef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
#undef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE 0
#undef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS 0
#undef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_PYSTON 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#ifndef CYTHON_USE_TYPE_SLOTS
#define CYTHON_USE_TYPE_SLOTS 1
#endif
#if PY_VERSION_HEX < 0x02070000
#undef CYTHON_USE_PYTYPE_LOOKUP
#define CYTHON_USE_PYTYPE_LOOKUP 0
#elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
#define CYTHON_USE_PYTYPE_LOOKUP 1
#endif
#if PY_MAJOR_VERSION < 3
#undef CYTHON_USE_ASYNC_SLOTS
#define CYTHON_USE_ASYNC_SLOTS 0
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
#define CYTHON_USE_ASYNC_SLOTS 1
#endif
#if PY_VERSION_HEX < 0x02070000
#undef CYTHON_USE_PYLONG_INTERNALS
#define CYTHON_USE_PYLONG_INTERNALS 0
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#ifndef CYTHON_USE_PYLIST_INTERNALS
#define CYTHON_USE_PYLIST_INTERNALS 1
#endif
#ifndef CYTHON_USE_UNICODE_INTERNALS
#define CYTHON_USE_UNICODE_INTERNALS 1
#endif
#if PY_VERSION_HEX < 0x030300F0
#undef CYTHON_USE_UNICODE_WRITER
#define CYTHON_USE_UNICODE_WRITER 0
#elif !defined(CYTHON_USE_UNICODE_WRITER)
#define CYTHON_USE_UNICODE_WRITER 1
#endif
#ifndef CYTHON_AVOID_BORROWED_REFS
#define CYTHON_AVOID_BORROWED_REFS 0
#endif
#ifndef CYTHON_ASSUME_SAFE_MACROS
#define CYTHON_ASSUME_SAFE_MACROS 1
#endif
#ifndef CYTHON_UNPACK_METHODS
#define CYTHON_UNPACK_METHODS 1
#endif
#ifndef CYTHON_FAST_THREAD_STATE
#define CYTHON_FAST_THREAD_STATE 1
#endif
#ifndef CYTHON_FAST_PYCALL
#define CYTHON_FAST_PYCALL 1
#endif
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
#endif
#ifndef CYTHON_USE_TP_FINALIZE
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
#endif
#ifndef CYTHON_USE_DICT_VERSIONS
#define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
#endif
#ifndef CYTHON_USE_EXC_INFO_STACK
#define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
#endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#undef SHIFT
#undef BASE
#undef MASK
#ifdef SIZEOF_VOID_P
enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
#endif
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
#if defined(__GNUC__)
#define CYTHON_RESTRICT __restrict__
#elif defined(_MSC_VER) && _MSC_VER >= 1400
#define CYTHON_RESTRICT __restrict
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_RESTRICT restrict
#else
#define CYTHON_RESTRICT
#endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
# if defined(__cplusplus)
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
# else
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
# define CYTHON_NCP_UNUSED
# else
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
#ifndef _MSC_STDINT_H_
#if _MSC_VER < 1300
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
#else
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
#endif
#endif
#else
#include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
#if defined(__cplusplus) && __cplusplus >= 201103L
#if __has_cpp_attribute(fallthrough)
#define CYTHON_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)
#define CYTHON_FALLTHROUGH [[clang::fallthrough]]
#elif __has_cpp_attribute(gnu::fallthrough)
#define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
#endif
#endif
#ifndef CYTHON_FALLTHROUGH
#if __has_attribute(fallthrough)
#define CYTHON_FALLTHROUGH __attribute__((fallthrough))
#else
#define CYTHON_FALLTHROUGH
#endif
#endif
#if defined(__clang__ ) && defined(__apple_build_version__)
#if __apple_build_version__ < 7000000
#undef CYTHON_FALLTHROUGH
#define CYTHON_FALLTHROUGH
#endif
#endif
#endif
#ifndef CYTHON_INLINE
#if defined(__clang__)
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
#elif defined(__GNUC__)
#define CYTHON_INLINE __inline__
#elif defined(_MSC_VER)
#define CYTHON_INLINE __inline
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_INLINE inline
#else
#define CYTHON_INLINE
#endif
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#define __Pyx_DefaultClassType PyClass_Type
#else
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
#define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
#define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
#define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
#define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
#ifndef METH_FASTCALL
#define METH_FASTCALL 0x80
#endif
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
Py_ssize_t nargs, PyObject *kwnames);
#else
#define __Pyx_PyCFunctionFast _PyCFunctionFast
#define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
#define PyObject_Malloc(s) PyMem_Malloc(s)
#define PyObject_Free(p) PyMem_Free(p)
#define PyObject_Realloc(p) PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
#define PyMem_RawMalloc(n) PyMem_Malloc(n)
#define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
#define PyMem_RawFree(p) PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
#define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
#define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
#define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
#define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
*key = PyThread_create_key();
return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
*key = Py_tss_NEEDS_INIT;
return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
PyThread_delete_key(*key);
*key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n) PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
#else
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
0 : _PyUnicode_Ready((PyObject *)(op)))
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
#define CYTHON_PEP393_ENABLED 0
#define PyUnicode_1BYTE_KIND 1
#define PyUnicode_2BYTE_KIND 2
#define PyUnicode_4BYTE_KIND 4
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
#else
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
#else
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
#define PyObject_ASCII(o) PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#ifndef PyObject_Unicode
#define PyObject_Unicode PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
#define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
#else
#define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
#define PyInt_Check(op) PyLong_Check(op)
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
#define PyInt_FromString PyLong_FromString
#define PyInt_FromUnicode PyLong_FromUnicode
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AS_LONG
#define PyInt_AsSsize_t PyLong_AsSsize_t
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#define PyNumber_Int PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBoolObject PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
#ifndef PyUnicode_InternFromString
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
#endif
#endif
#if PY_VERSION_HEX < 0x030200A4
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#else
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#endif
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
typedef struct {
unaryfunc am_await;
unaryfunc am_aiter;
unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#endif
#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINESg
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
float value;
memset(&value, 0xFF, sizeof(value));
return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif
#define __PYX_MARK_ERR_POS(f_index, lineno) \
{ __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
{ __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#define __PYX_HAVE__pyapprox__cython__adaptive_sparse_grid
#define __PYX_HAVE_API__pyapprox__cython__adaptive_sparse_grid
/* Early includes */
#include "pythread.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "pystate.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
(sizeof(type) < sizeof(Py_ssize_t)) ||\
(sizeof(type) > sizeof(Py_ssize_t) &&\
likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX) &&\
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
v == (type)PY_SSIZE_T_MIN))) ||\
(sizeof(type) == sizeof(Py_ssize_t) &&\
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
v == (type)PY_SSIZE_T_MAX))) )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
#include <cstdlib>
#define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
#define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
#define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
const Py_UNICODE *u_end = u;
while (*u_end++) ;
return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
(likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
PyObject* ascii_chars_u = NULL;
PyObject* ascii_chars_b = NULL;
const char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
if (strcmp(default_encoding_c, "ascii") == 0) {
__Pyx_sys_getdefaultencoding_not_ascii = 0;
} else {
char ascii_chars[128];
int c;
for (c = 0; c < 128; c++) {
ascii_chars[c] = c;
}
__Pyx_sys_getdefaultencoding_not_ascii = 1;
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
if (!ascii_chars_u) goto bad;
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
PyErr_Format(
PyExc_ValueError,
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
default_encoding_c);
goto bad;
}
Py_DECREF(ascii_chars_u);
Py_DECREF(ascii_chars_b);
}
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
Py_XDECREF(ascii_chars_u);
Py_XDECREF(ascii_chars_b);
return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
PyObject* sys;
PyObject* default_encoding = NULL;
char* default_encoding_c;
sys = PyImport_ImportModule("sys");
if (!sys) goto bad;
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
Py_DECREF(sys);
if (!default_encoding) goto bad;
default_encoding_c = PyBytes_AsString(default_encoding);
if (!default_encoding_c) goto bad;
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
Py_DECREF(default_encoding);
return 0;
bad:
Py_XDECREF(default_encoding);
return -1;
}
#endif
#endif
/* Test for GCC > 2.95 */
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
static const char *__pyx_f[] = {
"pyapprox/cython/adaptive_sparse_grid.pyx",
"stringsource",
};
/* MemviewSliceStruct.proto */
struct __pyx_memoryview_obj;
typedef struct {
struct __pyx_memoryview_obj *memview;
char *data;
Py_ssize_t shape[8];
Py_ssize_t strides[8];
Py_ssize_t suboffsets[8];
} __Pyx_memviewslice;
#define __Pyx_MemoryView_Len(m) (m.shape[0])
/* Atomics.proto */
#include <pythread.h>
#ifndef CYTHON_ATOMICS
#define CYTHON_ATOMICS 1
#endif
#define __pyx_atomic_int_type int
#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
(__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
!defined(__i386__)
#define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
#define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
#ifdef __PYX_DEBUG_ATOMICS
#warning "Using GNU atomics"
#endif
#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
#include <Windows.h>
#undef __pyx_atomic_int_type
#define __pyx_atomic_int_type LONG
#define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
#define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
#ifdef __PYX_DEBUG_ATOMICS
#pragma message ("Using MSVC atomics")
#endif
#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
#define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
#define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
#ifdef __PYX_DEBUG_ATOMICS
#warning "Using Intel atomics"
#endif
#else
#undef CYTHON_ATOMICS
#define CYTHON_ATOMICS 0
#ifdef __PYX_DEBUG_ATOMICS
#warning "Not using atomics"
#endif
#endif
typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
#if CYTHON_ATOMICS
#define __pyx_add_acquisition_count(memview)\
__pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
#define __pyx_sub_acquisition_count(memview)\
__pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
#else
#define __pyx_add_acquisition_count(memview)\
__pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
#define __pyx_sub_acquisition_count(memview)\
__pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
#endif
/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
#define __PYX_FORCE_INIT_THREADS 0
#endif
/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()
/* BufferFormatStructs.proto */
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
const char* name;
struct __Pyx_StructField_* fields;
size_t size;
size_t arraysize[8];
int ndim;
char typegroup;
char is_unsigned;
int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
__Pyx_TypeInfo* type;
const char* name;
size_t offset;
} __Pyx_StructField;
typedef struct {
__Pyx_StructField* field;
size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
__Pyx_StructField root;
__Pyx_BufFmt_StackElem* head;
size_t fmt_offset;
size_t new_count, enc_count;
size_t struct_alignment;
int is_complex;
char enc_type;
char new_packmode;
char enc_packmode;
char is_valid_array;
} __Pyx_BufFmt_Context;
/*--- Type declarations ---*/
struct __pyx_array_obj;
struct __pyx_MemviewEnum_obj;
struct __pyx_memoryview_obj;
struct __pyx_memoryviewslice_obj;
/* "View.MemoryView":105
*
* @cname("__pyx_array")
* cdef class array: # <<<<<<<<<<<<<<
*
* cdef:
*/
struct __pyx_array_obj {
PyObject_HEAD
struct __pyx_vtabstruct_array *__pyx_vtab;
char *data;
Py_ssize_t len;
char *format;
int ndim;
Py_ssize_t *_shape;
Py_ssize_t *_strides;
Py_ssize_t itemsize;
PyObject *mode;
PyObject *_format;
void (*callback_free_data)(void *);
int free_data;
int dtype_is_object;
};
/* "View.MemoryView":279
*
* @cname('__pyx_MemviewEnum')
* cdef class Enum(object): # <<<<<<<<<<<<<<
* cdef object name
* def __init__(self, name):
*/
struct __pyx_MemviewEnum_obj {
PyObject_HEAD
PyObject *name;
};
/* "View.MemoryView":330
*
* @cname('__pyx_memoryview')
* cdef class memoryview(object): # <<<<<<<<<<<<<<
*
* cdef object obj
*/
struct __pyx_memoryview_obj {
PyObject_HEAD
struct __pyx_vtabstruct_memoryview *__pyx_vtab;
PyObject *obj;
PyObject *_size;
PyObject *_array_interface;
PyThread_type_lock lock;
__pyx_atomic_int acquisition_count[2];
__pyx_atomic_int *acquisition_count_aligned_p;
Py_buffer view;
int flags;
int dtype_is_object;
__Pyx_TypeInfo *typeinfo;
};
/* "View.MemoryView":965
*
* @cname('__pyx_memoryviewslice')
* cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<<
* "Internal class for passing memoryview slices to Python"
*
*/
struct __pyx_memoryviewslice_obj {
struct __pyx_memoryview_obj __pyx_base;
__Pyx_memviewslice from_slice;
PyObject *from_object;
PyObject *(*to_object_func)(char *);
int (*to_dtype_func)(char *, PyObject *);
};
/* "View.MemoryView":105
*
* @cname("__pyx_array")
* cdef class array: # <<<<<<<<<<<<<<
*
* cdef:
*/
struct __pyx_vtabstruct_array {
PyObject *(*get_memview)(struct __pyx_array_obj *);
};
static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
/* "View.MemoryView":330
*
* @cname('__pyx_memoryview')
* cdef class memoryview(object): # <<<<<<<<<<<<<<
*
* cdef object obj
*/
struct __pyx_vtabstruct_memoryview {
char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
};
static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
/* "View.MemoryView":965
*
* @cname('__pyx_memoryviewslice')
* cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<<
* "Internal class for passing memoryview slices to Python"
*
*/
struct __pyx_vtabstruct__memoryviewslice {
struct __pyx_vtabstruct_memoryview __pyx_base;
};
static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
#define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
typedef struct {
void (*INCREF)(void*, PyObject*, int);
void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int);
void* (*SetupContext)(const char*, int, const char*);
void (*FinishContext)(void**);
} __Pyx_RefNannyAPIStruct;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
if (acquire_gil) {\
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
PyGILState_Release(__pyx_gilstate_save);\
} else {\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
}
#else
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
#define __Pyx_RefNannyFinishContext()\
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
#define __Pyx_RefNannyDeclarations
#define __Pyx_RefNannySetupContext(name, acquire_gil)
#define __Pyx_RefNannyFinishContext()
#define __Pyx_INCREF(r) Py_INCREF(r)
#define __Pyx_DECREF(r) Py_DECREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_XINCREF(r) Py_XINCREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_XGOTREF(r)
#define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_XDECREF(tmp);\
} while (0)
#define __Pyx_DECREF_SET(r, v) do {\
PyObject *tmp = (PyObject *) r;\
r = v; __Pyx_DECREF(tmp);\
} while (0)
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif
/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
const char* function_name);
/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
int result = PyDict_Contains(dict, item);
return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}
/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
(likely(PyDict_CheckExact(obj)) ?\
__Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
#endif
/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
#endif
/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
(sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
static size_t __pyx_pyframe_localsplus_offset = 0;
#include "frameobject.h"
#define __Pxy_PyFrame_Initialize_Offsets()\
((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
(void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
#define __Pyx_PyFrame_GetLocalsplus(frame)\
(assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif
/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif
/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif
/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred() PyErr_Occurred()
#endif
/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
#endif
/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
/* UnicodeAsUCS4.proto */
static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*);
/* object_ord.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyObject_Ord(c)\
(likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c))
#else
#define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c)
#endif
static long __Pyx__PyObject_Ord(PyObject* c);
/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
(is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
__Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
int is_list, int wraparound, int boundscheck);
/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);
/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif
/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
/* UnpackTupleError.proto */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
/* UnpackTuple2.proto */
#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
(likely(is_tuple || PyTuple_Check(tuple)) ?\
(likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
__Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
(__Pyx_UnpackTupleError(tuple, 2), -1)) :\
__Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
static int __Pyx_unpack_tuple2_generic(
PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
(is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
__Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
(PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
(__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
__Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
(PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
int is_list, int wraparound, int boundscheck);
/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
PyListObject* L = (PyListObject*) list;
Py_ssize_t len = Py_SIZE(list);
if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
Py_INCREF(x);
PyList_SET_ITEM(list, len, x);
Py_SIZE(list) = len+1;
return 0;
}
return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif
/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
(version_var) = __PYX_GET_DICT_VERSION(dict);\
(cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
static PY_UINT64_T __pyx_dict_version = 0;\
static PyObject *__pyx_dict_cached_value = NULL;\
if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
(VAR) = __pyx_dict_cached_value;\
} else {\
(VAR) = __pyx_dict_cached_value = (LOOKUP);\
__pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
}\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict) (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
#endif
/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name) {\
static PY_UINT64_T __pyx_dict_version = 0;\
static PyObject *__pyx_dict_cached_value = NULL;\
(var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
(likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
__Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name) {\
PY_UINT64_T __pyx_dict_version;\
PyObject *__pyx_dict_cached_value;\
(var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif
/* MemviewSliceInit.proto */
#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
#define __Pyx_MEMVIEW_DIRECT 1
#define __Pyx_MEMVIEW_PTR 2
#define __Pyx_MEMVIEW_FULL 4
#define __Pyx_MEMVIEW_CONTIG 8
#define __Pyx_MEMVIEW_STRIDED 16
#define __Pyx_MEMVIEW_FOLLOW 32
#define __Pyx_IS_C_CONTIG 1
#define __Pyx_IS_F_CONTIG 2
static int __Pyx_init_memviewslice(
struct __pyx_memoryview_obj *memview,
int ndim,
__Pyx_memviewslice *memviewslice,
int memview_is_new_reference);
static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
__pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
__pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
__Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
/* IncludeStringH.proto */
#include <string.h>
/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif
/* None.proto */
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
/* UnaryNegOverflows.proto */
#define UNARY_NEG_WOULD_OVERFLOW(x)\
(((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
#endif
/* decode_c_string_utf16.proto */
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
int byteorder = 0;
return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
int byteorder = -1;
return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
int byteorder = 1;
return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
}
/* decode_c_string.proto */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
const char* cstring, Py_ssize_t start, Py_ssize_t stop,
const char* encoding, const char* errors,
PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
#endif
/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif
/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
#endif
/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif
/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif
/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
PyListObject* L = (PyListObject*) list;
Py_ssize_t len = Py_SIZE(list);
if (likely(L->allocated > len)) {
Py_INCREF(x);
PyList_SET_ITEM(list, len, x);
Py_SIZE(list) = len+1;
return 0;
}
return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif
/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
(inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif
/* ListExtend.proto */
static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
#if CYTHON_COMPILING_IN_CPYTHON
PyObject* none = _PyList_Extend((PyListObject*)L, v);
if (unlikely(!none))
return -1;
Py_DECREF(none);
return 0;
#else
return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
#endif
}
/* None.proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);
/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif
/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif
/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);
/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);
/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
/* CythonFunctionShared.proto */
#define __Pyx_CyFunction_USED 1
#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
#define __Pyx_CYFUNCTION_CCLASS 0x04
#define __Pyx_CyFunction_GetClosure(f)\
(((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f)\
(((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f)\
((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
PyObject *func_weakreflist;
#endif
PyObject *func_dict;
PyObject *func_name;
PyObject *func_qualname;
PyObject *func_doc;
PyObject *func_globals;
PyObject *func_code;
PyObject *func_closure;
PyObject *func_classobj;
void *defaults;
int defaults_pyobjects;
size_t defaults_size; // used by FusedFunction for copying defaults
int flags;
PyObject *defaults_tuple;
PyObject *defaults_kwdict;
PyObject *(*defaults_getter)(PyObject *);
PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
int flags, PyObject* qualname,
PyObject *self,
PyObject *module, PyObject *globals,
PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
size_t size,
int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
PyObject *dict);
static int __pyx_CyFunction_init(void);
/* FusedFunction.proto */
typedef struct {
__pyx_CyFunctionObject func;
PyObject *__signatures__;
PyObject *type;
PyObject *self;
} __pyx_FusedFunctionObject;
static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
PyObject *qualname, PyObject *closure,
PyObject *module, PyObject *globals,
PyObject *code);
static int __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self);
static PyTypeObject *__pyx_FusedFunctionType = NULL;
static int __pyx_FusedFunction_init(void);
#define __Pyx_FusedFunction_USED
/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif
/* CodeObjectCache.proto */
typedef struct {
PyCodeObject* code_object;
int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
int count;
int max_count;
__Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename);
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
#define __Pyx_GetBuffer PyObject_GetBuffer
#define __Pyx_ReleaseBuffer PyBuffer_Release
#endif
/* BufferStructDeclare.proto */
typedef struct {
Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
size_t refcount;
Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
__Pyx_Buffer *rcbuffer;
char *data;
__Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;
/* MemviewSliceIsContig.proto */
static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
/* OverlappingSlices.proto */
static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
__Pyx_memviewslice *slice2,
int ndim, size_t itemsize);
/* Capsule.proto */
static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
/* IsLittleEndian.proto */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
/* BufferFormatCheck.proto */
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
__Pyx_BufFmt_StackElem* stack,
__Pyx_TypeInfo* type);
/* TypeInfoCompare.proto */
static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
/* MemviewSliceValidateAndInit.proto */
static int __Pyx_ValidateAndInit_memviewslice(
int *axes_specs,
int c_or_f_flag,
int buf_flags,
int ndim,
__Pyx_TypeInfo *dtype,
__Pyx_BufFmt_StackElem stack[],
__Pyx_memviewslice *memviewslice,
PyObject *original_obj);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *, int writable_flag);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_long(PyObject *, int writable_flag);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_int(PyObject *, int writable_flag);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_long(PyObject *, int writable_flag);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
/* MemviewSliceCopyTemplate.proto */
static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
const char *mode, int ndim,
size_t sizeof_dtype, int contig_flag,
int dtype_is_object);
/* BytesContains.proto */
static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character);
/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
/* ImportNumPyArray.proto */
static PyObject *__pyx_numpy_ndarray = NULL;
static PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void);
/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
/* CIntFromPy.proto */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
/* ObjectToMemviewSlice.proto */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *, int writable_flag);
/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);
/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
/* Module declarations from 'cython.view' */
/* Module declarations from 'cython' */
/* Module declarations from 'pyapprox.cython.adaptive_sparse_grid' */
static PyTypeObject *__pyx_array_type = 0;
static PyTypeObject *__pyx_MemviewEnum_type = 0;
static PyTypeObject *__pyx_memoryview_type = 0;
static PyTypeObject *__pyx_memoryviewslice_type = 0;
static PyObject *generic = 0;
static PyObject *strided = 0;
static PyObject *indirect = 0;
static PyObject *contiguous = 0;
static PyObject *indirect_contiguous = 0;
static int __pyx_memoryview_thread_locks_used;
static PyThread_type_lock __pyx_memoryview_thread_locks[8];
static PyObject *__pyx_fuse_0__pyx_f_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(__Pyx_memviewslice, __Pyx_memviewslice, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_fuse_1__pyx_f_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(__Pyx_memviewslice, __Pyx_memviewslice, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
static void *__pyx_align_pointer(void *, size_t); /*proto*/
static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
static PyObject *_unellipsify(PyObject *, int); /*proto*/
static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/
static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_long = { "long", NULL, sizeof(long), { 0 }, 0, IS_UNSIGNED(long) ? 'U' : 'I', IS_UNSIGNED(long), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 };
#define __Pyx_MODULE_NAME "pyapprox.cython.adaptive_sparse_grid"
extern int __pyx_module_is_main_pyapprox__cython__adaptive_sparse_grid;
int __pyx_module_is_main_pyapprox__cython__adaptive_sparse_grid = 0;
/* Implementation of 'pyapprox.cython.adaptive_sparse_grid' */
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_IndexError;
static const char __pyx_k_[] = "()";
static const char __pyx_k_O[] = "O";
static const char __pyx_k_c[] = "c";
static const char __pyx_k_s[] = "s";
static const char __pyx_k__2[] = "|";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_np[] = "np";
static const char __pyx_k_int[] = "int";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_obj[] = "obj";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_base[] = "base";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_kind[] = "kind";
static const char __pyx_k_long[] = "long";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mode[] = "mode";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_ndim[] = "ndim";
static const char __pyx_k_pack[] = "pack";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_step[] = "step";
static const char __pyx_k_stop[] = "stop";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_ASCII[] = "ASCII";
static const char __pyx_k_class[] = "__class__";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_empty[] = "empty";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_flags[] = "flags";
static const char __pyx_k_int32[] = "int32";
static const char __pyx_k_int64[] = "int64";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_strip[] = "strip";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_struct[] = "struct";
static const char __pyx_k_unpack[] = "unpack";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_fortran[] = "fortran";
static const char __pyx_k_memview[] = "memview";
static const char __pyx_k_Ellipsis[] = "Ellipsis";
static const char __pyx_k_defaults[] = "defaults";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_itemsize[] = "itemsize";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_new_index[] = "new_index";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_IndexError[] = "IndexError";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_signatures[] = "signatures";
static const char __pyx_k_MemoryError[] = "MemoryError";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_smolyak_coeffs[] = "smolyak_coeffs";
static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_subspace_indices[] = "subspace_indices";
static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
static const char __pyx_k_No_matching_signature_found[] = "No matching signature found";
static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
static const char __pyx_k_pyx_fuse_0update_smolyak_coeff[] = "__pyx_fuse_0update_smolyak_coefficients_pyx";
static const char __pyx_k_pyx_fuse_1update_smolyak_coeff[] = "__pyx_fuse_1update_smolyak_coefficients_pyx";
static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
static const char __pyx_k_pyapprox_cython_adaptive_sparse[] = "pyapprox/cython/adaptive_sparse_grid.pyx";
static const char __pyx_k_update_smolyak_coefficients_pyx[] = "update_smolyak_coefficients_pyx";
static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
static const char __pyx_k_Expected_at_least_d_argument_s_g[] = "Expected at least %d argument%s, got %d";
static const char __pyx_k_Function_call_with_ambiguous_arg[] = "Function call with ambiguous argument types";
static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
static const char __pyx_k_pyapprox_cython_adaptive_sparse_2[] = "pyapprox.cython.adaptive_sparse_grid";
static PyObject *__pyx_kp_s_;
static PyObject *__pyx_n_s_ASCII;
static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor;
static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
static PyObject *__pyx_n_s_Ellipsis;
static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
static PyObject *__pyx_kp_s_Expected_at_least_d_argument_s_g;
static PyObject *__pyx_kp_s_Function_call_with_ambiguous_arg;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
static PyObject *__pyx_kp_s_MemoryView_of_r_object;
static PyObject *__pyx_kp_s_No_matching_signature_found;
static PyObject *__pyx_n_b_O;
static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_View_MemoryView;
static PyObject *__pyx_kp_s__2;
static PyObject *__pyx_n_s_allocate_buffer;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_base;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_n_u_c;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_kp_s_contiguous_and_direct;
static PyObject *__pyx_kp_s_contiguous_and_indirect;
static PyObject *__pyx_n_s_defaults;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dtype_is_object;
static PyObject *__pyx_n_s_empty;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_fortran;
static PyObject *__pyx_n_u_fortran;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_int;
static PyObject *__pyx_n_s_int32;
static PyObject *__pyx_n_s_int64;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
static PyObject *__pyx_n_s_kind;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_long;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_memview;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_new_index;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_pack;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_kp_s_pyapprox_cython_adaptive_sparse;
static PyObject *__pyx_n_s_pyapprox_cython_adaptive_sparse_2;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_fuse_0update_smolyak_coeff;
static PyObject *__pyx_n_s_pyx_fuse_1update_smolyak_coeff;
static PyObject *__pyx_n_s_pyx_getbuffer;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_Enum;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_s;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_signatures;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_smolyak_coeffs;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_step;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_kp_s_strided_and_direct;
static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
static PyObject *__pyx_kp_s_strided_and_indirect;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_struct;
static PyObject *__pyx_n_s_subspace_indices;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
static PyObject *__pyx_n_s_unpack;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_update_smolyak_coefficients_pyx;
static PyObject *__pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
static PyObject *__pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_2__pyx_fuse_0update_smolyak_coefficients_pyx(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_new_index, __Pyx_memviewslice __pyx_v_subspace_indices, PyObject *__pyx_v_smolyak_coeffs); /* proto */
static PyObject *__pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_4__pyx_fuse_1update_smolyak_coefficients_pyx(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_new_index, __Pyx_memviewslice __pyx_v_subspace_indices, PyObject *__pyx_v_smolyak_coeffs); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */
static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_184977713;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__19;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_codeobj__24;
static PyObject *__pyx_codeobj__31;
/* Late includes */
/* "pyapprox/cython/adaptive_sparse_grid.pyx":11
* @cython.boundscheck(False) # Deactivate bounds checking
* @cython.wraparound(False) # Deactivate negative indexing.
* cpdef update_smolyak_coefficients_pyx(mixed_type [:] new_index, mixed_type [:,:] subspace_indices, smolyak_coeffs): # <<<<<<<<<<<<<<
*
* if mixed_type is int:
*/
/* Python wrapper */
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_1update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_8pyapprox_6cython_20adaptive_sparse_grid_1update_smolyak_coefficients_pyx = {"update_smolyak_coefficients_pyx", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_1update_smolyak_coefficients_pyx, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_1update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_signatures = 0;
PyObject *__pyx_v_args = 0;
PyObject *__pyx_v_kwargs = 0;
CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
PyObject* values[4] = {0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 11, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 11, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 11, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 11, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
}
__pyx_v_signatures = values[0];
__pyx_v_args = values[1];
__pyx_v_kwargs = values[2];
__pyx_v_defaults = values[3];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
PyObject *__pyx_v_dest_sig = NULL;
Py_ssize_t __pyx_v_i;
PyTypeObject *__pyx_v_ndarray = 0;
__Pyx_memviewslice __pyx_v_memslice;
Py_ssize_t __pyx_v_itemsize;
int __pyx_v_dtype_signed;
char __pyx_v_kind;
int __pyx_v_int_is_signed;
int __pyx_v_long_is_signed;
PyObject *__pyx_v_arg = NULL;
PyObject *__pyx_v_dtype = NULL;
PyObject *__pyx_v_arg_base = NULL;
PyObject *__pyx_v_candidates = NULL;
PyObject *__pyx_v_sig = NULL;
int __pyx_v_match_found;
PyObject *__pyx_v_src_sig = NULL;
PyObject *__pyx_v_dst_type = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
PyObject *__pyx_t_6 = NULL;
long __pyx_t_7;
__Pyx_memviewslice __pyx_t_8;
Py_ssize_t __pyx_t_9;
int __pyx_t_10;
int __pyx_t_11;
PyObject *__pyx_t_12 = NULL;
PyObject *__pyx_t_13 = NULL;
PyObject *__pyx_t_14 = NULL;
Py_ssize_t __pyx_t_15;
Py_ssize_t __pyx_t_16;
Py_ssize_t __pyx_t_17;
int __pyx_t_18;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("update_smolyak_coefficients_pyx", 0);
__Pyx_INCREF(__pyx_v_kwargs);
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
__pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_3 = (__pyx_v_kwargs != Py_None);
__pyx_t_4 = (__pyx_t_3 != 0);
if (__pyx_t_4) {
} else {
__pyx_t_2 = __pyx_t_4;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_t_3 = ((!__pyx_t_4) != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L4_bool_binop_done:;
if (__pyx_t_2) {
__Pyx_INCREF(Py_None);
__Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
}
__pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
__pyx_t_1 = 0;
__pyx_v_itemsize = -1L;
__pyx_v_int_is_signed = (!((((int)-1L) > 0) != 0));
__pyx_v_long_is_signed = (!((((long)-1L) > 0) != 0));
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_t_2 = ((0 < __pyx_t_5) != 0);
if (__pyx_t_2) {
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
__Pyx_INCREF(__pyx_t_1);
__pyx_v_arg = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L6;
}
__pyx_t_3 = (__pyx_v_kwargs != Py_None);
__pyx_t_4 = (__pyx_t_3 != 0);
if (__pyx_t_4) {
} else {
__pyx_t_2 = __pyx_t_4;
goto __pyx_L7_bool_binop_done;
}
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_new_index, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_t_3 = (__pyx_t_4 != 0);
__pyx_t_2 = __pyx_t_3;
__pyx_L7_bool_binop_done:;
if (__pyx_t_2) {
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_new_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_arg = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L6;
}
/*else*/ {
if (unlikely(__pyx_v_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_INCREF(__pyx_int_3);
__Pyx_GIVEREF(__pyx_int_3);
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
__Pyx_INCREF(__pyx_n_s_s);
__Pyx_GIVEREF(__pyx_n_s_s);
PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_s);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_L6:;
while (1) {
__pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_v_dtype = __pyx_t_6;
__pyx_t_6 = 0;
goto __pyx_L12;
}
__pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_v_arg_base = __pyx_t_6;
__pyx_t_6 = 0;
__pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_v_dtype = __pyx_t_6;
__pyx_t_6 = 0;
goto __pyx_L13;
}
/*else*/ {
__Pyx_INCREF(Py_None);
__pyx_v_dtype = Py_None;
}
__pyx_L13:;
goto __pyx_L12;
}
/*else*/ {
__Pyx_INCREF(Py_None);
__pyx_v_dtype = Py_None;
}
__pyx_L12:;
__pyx_v_itemsize = -1L;
__pyx_t_2 = (__pyx_v_dtype != Py_None);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_v_itemsize = __pyx_t_5;
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_v_kind = __pyx_t_7;
__pyx_v_dtype_signed = (__pyx_v_kind == 'i');
switch (__pyx_v_kind) {
case 'i':
case 'u':
__pyx_t_2 = (((sizeof(int)) == __pyx_v_itemsize) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_3 = __pyx_t_2;
goto __pyx_L16_bool_binop_done;
}
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 1) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_3 = __pyx_t_2;
goto __pyx_L16_bool_binop_done;
}
__pyx_t_2 = ((!((__pyx_v_int_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_3 = __pyx_t_2;
__pyx_L16_bool_binop_done:;
if (__pyx_t_3) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
goto __pyx_L10_break;
}
__pyx_t_2 = (((sizeof(long)) == __pyx_v_itemsize) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_3 = __pyx_t_2;
goto __pyx_L20_bool_binop_done;
}
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 1) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_3 = __pyx_t_2;
goto __pyx_L20_bool_binop_done;
}
__pyx_t_2 = ((!((__pyx_v_long_is_signed ^ __pyx_v_dtype_signed) != 0)) != 0);
__pyx_t_3 = __pyx_t_2;
__pyx_L20_bool_binop_done:;
if (__pyx_t_3) {
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_long, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
goto __pyx_L10_break;
}
break;
case 'f':
break;
case 'c':
break;
case 'O':
break;
default: break;
}
}
}
__pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_2) {
} else {
__pyx_t_3 = __pyx_t_2;
goto __pyx_L24_bool_binop_done;
}
__pyx_t_2 = ((__pyx_v_itemsize == (sizeof(int))) != 0);
__pyx_t_3 = __pyx_t_2;
__pyx_L24_bool_binop_done:;
if (__pyx_t_3) {
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_arg, 0);
__pyx_v_memslice = __pyx_t_8;
__pyx_t_3 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_3) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_int, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
goto __pyx_L10_break;
}
/*else*/ {
PyErr_Clear();
}
}
__pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
if (!__pyx_t_2) {
} else {
__pyx_t_3 = __pyx_t_2;
goto __pyx_L28_bool_binop_done;
}
__pyx_t_2 = ((__pyx_v_itemsize == (sizeof(long))) != 0);
__pyx_t_3 = __pyx_t_2;
__pyx_L28_bool_binop_done:;
if (__pyx_t_3) {
__pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(__pyx_v_arg, 0);
__pyx_v_memslice = __pyx_t_8;
__pyx_t_3 = (__pyx_v_memslice.memview != 0);
if (__pyx_t_3) {
__PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_long, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
goto __pyx_L10_break;
}
/*else*/ {
PyErr_Clear();
}
}
if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
goto __pyx_L10_break;
}
__pyx_L10_break:;
__pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_v_candidates = ((PyObject*)__pyx_t_6);
__pyx_t_6 = 0;
__pyx_t_5 = 0;
if (unlikely(__pyx_v_signatures == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_6);
__pyx_t_6 = __pyx_t_1;
__pyx_t_1 = 0;
while (1) {
__pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
if (unlikely(__pyx_t_11 == 0)) break;
if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_v_match_found = 0;
__pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_13);
__pyx_t_14 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
__pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
if (likely(__pyx_t_14)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
__Pyx_INCREF(__pyx_t_14);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_13, function);
}
}
__pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s_) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s_);
__Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_12);
__Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
__pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_13);
__Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
__pyx_t_12 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
__pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
if (likely(__pyx_t_12)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
__Pyx_INCREF(__pyx_t_12);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_13, function);
}
}
__pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__2) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__2);
__Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
__Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_t_16 = __pyx_t_15;
for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
__pyx_v_i = __pyx_t_17;
__pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
__Pyx_INCREF(__pyx_t_1);
__Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_3 = (__pyx_v_dst_type != Py_None);
__pyx_t_2 = (__pyx_t_3 != 0);
if (__pyx_t_2) {
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
if (__pyx_t_2) {
__pyx_v_match_found = 1;
goto __pyx_L36;
}
/*else*/ {
__pyx_v_match_found = 0;
goto __pyx_L34_break;
}
__pyx_L36:;
}
}
__pyx_L34_break:;
__pyx_t_2 = (__pyx_v_match_found != 0);
if (__pyx_t_2) {
__pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 11, __pyx_L1_error)
}
}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
__pyx_t_3 = ((!__pyx_t_2) != 0);
if (__pyx_t_3) {
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_t_3 = ((__pyx_t_9 > 1) != 0);
if (__pyx_t_3) {
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__PYX_ERR(0, 11, __pyx_L1_error)
}
/*else*/ {
__Pyx_XDECREF(__pyx_r);
if (unlikely(__pyx_v_signatures == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(0, 11, __pyx_L1_error)
}
__pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_r = __pyx_t_6;
__pyx_t_6 = 0;
goto __pyx_L0;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_12);
__Pyx_XDECREF(__pyx_t_13);
__Pyx_XDECREF(__pyx_t_14);
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_dest_sig);
__Pyx_XDECREF(__pyx_v_ndarray);
__Pyx_XDECREF(__pyx_v_arg);
__Pyx_XDECREF(__pyx_v_dtype);
__Pyx_XDECREF(__pyx_v_arg_base);
__Pyx_XDECREF(__pyx_v_candidates);
__Pyx_XDECREF(__pyx_v_sig);
__Pyx_XDECREF(__pyx_v_src_sig);
__Pyx_XDECREF(__pyx_v_dst_type);
__Pyx_XDECREF(__pyx_v_kwargs);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_3__pyx_fuse_0update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_1update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_fuse_0__pyx_f_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(__Pyx_memviewslice __pyx_v_new_index, __Pyx_memviewslice __pyx_v_subspace_indices, PyObject *__pyx_v_smolyak_coeffs, CYTHON_UNUSED int __pyx_skip_dispatch) {
PyObject *__pyx_v_dtype = NULL;
__Pyx_memviewslice __pyx_v_smolyak_coeffs_view = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_v_ii;
int __pyx_v_jj;
int __pyx_v_num_vars;
int __pyx_v_num_subspace_indices;
__Pyx_memviewslice __pyx_v_diff = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_v_diff_sum;
int __pyx_v_update;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
__Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
__Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_t_7;
int __pyx_t_8;
int __pyx_t_9;
int __pyx_t_10;
int __pyx_t_11;
int __pyx_t_12;
Py_ssize_t __pyx_t_13;
Py_ssize_t __pyx_t_14;
Py_ssize_t __pyx_t_15;
Py_ssize_t __pyx_t_16;
int __pyx_t_17;
int __pyx_t_18;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_0update_smolyak_coefficients_pyx", 0);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":14
*
* if mixed_type is int:
* dtype = np.int32 # <<<<<<<<<<<<<<
* if mixed_type is long:
* dtype = np.int64
*/
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_dtype = __pyx_t_2;
__pyx_t_2 = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":18
* dtype = np.int64
*
* cdef double [:] smolyak_coeffs_view = smolyak_coeffs # <<<<<<<<<<<<<<
*
* cdef int ii,jj
*/
__pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_smolyak_coeffs, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 18, __pyx_L1_error)
__pyx_v_smolyak_coeffs_view = __pyx_t_3;
__pyx_t_3.memview = NULL;
__pyx_t_3.data = NULL;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":21
*
* cdef int ii,jj
* cdef int num_vars = subspace_indices.shape[0] # <<<<<<<<<<<<<<
* cdef int num_subspace_indices = subspace_indices.shape[1]
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
*/
__pyx_v_num_vars = (__pyx_v_subspace_indices.shape[0]);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":22
* cdef int ii,jj
* cdef int num_vars = subspace_indices.shape[0]
* cdef int num_subspace_indices = subspace_indices.shape[1] # <<<<<<<<<<<<<<
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
* cdef int diff_sum = 0
*/
__pyx_v_num_subspace_indices = (__pyx_v_subspace_indices.shape[1]);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":23
* cdef int num_vars = subspace_indices.shape[0]
* cdef int num_subspace_indices = subspace_indices.shape[1]
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype) # <<<<<<<<<<<<<<
* cdef int diff_sum = 0
* update = True
*/
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_num_vars); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_diff = __pyx_t_6;
__pyx_t_6.memview = NULL;
__pyx_t_6.data = NULL;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":24
* cdef int num_subspace_indices = subspace_indices.shape[1]
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
* cdef int diff_sum = 0 # <<<<<<<<<<<<<<
* update = True
*
*/
__pyx_v_diff_sum = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":25
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
* cdef int diff_sum = 0
* update = True # <<<<<<<<<<<<<<
*
* for ii in range(num_subspace_indices):
*/
__pyx_v_update = 1;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":27
* update = True
*
* for ii in range(num_subspace_indices): # <<<<<<<<<<<<<<
* diff_sum = 0
* update = True
*/
__pyx_t_7 = __pyx_v_num_subspace_indices;
__pyx_t_8 = __pyx_t_7;
for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
__pyx_v_ii = __pyx_t_9;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":28
*
* for ii in range(num_subspace_indices):
* diff_sum = 0 # <<<<<<<<<<<<<<
* update = True
* for jj in range(num_vars):
*/
__pyx_v_diff_sum = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":29
* for ii in range(num_subspace_indices):
* diff_sum = 0
* update = True # <<<<<<<<<<<<<<
* for jj in range(num_vars):
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
*/
__pyx_v_update = 1;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":30
* diff_sum = 0
* update = True
* for jj in range(num_vars): # <<<<<<<<<<<<<<
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj]
*/
__pyx_t_10 = __pyx_v_num_vars;
__pyx_t_11 = __pyx_t_10;
for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
__pyx_v_jj = __pyx_t_12;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":31
* update = True
* for jj in range(num_vars):
* diff[jj] = new_index[jj]-subspace_indices[jj,ii] # <<<<<<<<<<<<<<
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1):
*/
__pyx_t_13 = __pyx_v_jj;
__pyx_t_14 = __pyx_v_jj;
__pyx_t_15 = __pyx_v_ii;
__pyx_t_16 = __pyx_v_jj;
*((int *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_16 * __pyx_v_diff.strides[0]) )) = ((*((int *) ( /* dim=0 */ (__pyx_v_new_index.data + __pyx_t_13 * __pyx_v_new_index.strides[0]) ))) - (*((int *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_subspace_indices.data + __pyx_t_14 * __pyx_v_subspace_indices.strides[0]) ) + __pyx_t_15 * __pyx_v_subspace_indices.strides[1]) ))));
/* "pyapprox/cython/adaptive_sparse_grid.pyx":32
* for jj in range(num_vars):
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj] # <<<<<<<<<<<<<<
* if (diff[jj]<0) or (diff[jj]>1):
* update = False
*/
__pyx_t_15 = __pyx_v_jj;
__pyx_v_diff_sum = (__pyx_v_diff_sum + (*((int *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_15 * __pyx_v_diff.strides[0]) ))));
/* "pyapprox/cython/adaptive_sparse_grid.pyx":33
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1): # <<<<<<<<<<<<<<
* update = False
* break
*/
__pyx_t_15 = __pyx_v_jj;
__pyx_t_18 = (((*((int *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_15 * __pyx_v_diff.strides[0]) ))) < 0) != 0);
if (!__pyx_t_18) {
} else {
__pyx_t_17 = __pyx_t_18;
goto __pyx_L8_bool_binop_done;
}
__pyx_t_15 = __pyx_v_jj;
__pyx_t_18 = (((*((int *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_15 * __pyx_v_diff.strides[0]) ))) > 1) != 0);
__pyx_t_17 = __pyx_t_18;
__pyx_L8_bool_binop_done:;
if (__pyx_t_17) {
/* "pyapprox/cython/adaptive_sparse_grid.pyx":34
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1):
* update = False # <<<<<<<<<<<<<<
* break
* if update:
*/
__pyx_v_update = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":35
* if (diff[jj]<0) or (diff[jj]>1):
* update = False
* break # <<<<<<<<<<<<<<
* if update:
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
*/
goto __pyx_L6_break;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":33
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1): # <<<<<<<<<<<<<<
* update = False
* break
*/
}
}
__pyx_L6_break:;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":36
* update = False
* break
* if update: # <<<<<<<<<<<<<<
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
* return smolyak_coeffs
*/
__pyx_t_17 = (__pyx_v_update != 0);
if (__pyx_t_17) {
/* "pyapprox/cython/adaptive_sparse_grid.pyx":37
* break
* if update:
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum # <<<<<<<<<<<<<<
* return smolyak_coeffs
*/
__pyx_t_15 = __pyx_v_ii;
*((double *) ( /* dim=0 */ (__pyx_v_smolyak_coeffs_view.data + __pyx_t_15 * __pyx_v_smolyak_coeffs_view.strides[0]) )) += pow(-1., ((double)__pyx_v_diff_sum));
/* "pyapprox/cython/adaptive_sparse_grid.pyx":36
* update = False
* break
* if update: # <<<<<<<<<<<<<<
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
* return smolyak_coeffs
*/
}
}
/* "pyapprox/cython/adaptive_sparse_grid.pyx":38
* if update:
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
* return smolyak_coeffs # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_smolyak_coeffs);
__pyx_r = __pyx_v_smolyak_coeffs;
goto __pyx_L0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":11
* @cython.boundscheck(False) # Deactivate bounds checking
* @cython.wraparound(False) # Deactivate negative indexing.
* cpdef update_smolyak_coefficients_pyx(mixed_type [:] new_index, mixed_type [:,:] subspace_indices, smolyak_coeffs): # <<<<<<<<<<<<<<
*
* if mixed_type is int:
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.update_smolyak_coefficients_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_dtype);
__PYX_XDEC_MEMVIEW(&__pyx_v_smolyak_coeffs_view, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_diff, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_3__pyx_fuse_0update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_0__pyx_mdef_8pyapprox_6cython_20adaptive_sparse_grid_3__pyx_fuse_0update_smolyak_coefficients_pyx = {"__pyx_fuse_0update_smolyak_coefficients_pyx", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_3__pyx_fuse_0update_smolyak_coefficients_pyx, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_3__pyx_fuse_0update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_new_index = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_subspace_indices = { 0, 0, { 0 }, { 0 }, { 0 } };
PyObject *__pyx_v_smolyak_coeffs = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__pyx_fuse_0update_smolyak_coefficients_pyx (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_new_index,&__pyx_n_s_subspace_indices,&__pyx_n_s_smolyak_coeffs,0};
PyObject* values[3] = {0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_index)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subspace_indices)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fuse_0update_smolyak_coefficients_pyx", 1, 3, 3, 1); __PYX_ERR(0, 11, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_smolyak_coeffs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fuse_0update_smolyak_coefficients_pyx", 1, 3, 3, 2); __PYX_ERR(0, 11, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_0update_smolyak_coefficients_pyx") < 0)) __PYX_ERR(0, 11, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
}
__pyx_v_new_index = __Pyx_PyObject_to_MemoryviewSlice_ds_int(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_new_index.memview)) __PYX_ERR(0, 11, __pyx_L3_error)
__pyx_v_subspace_indices = __Pyx_PyObject_to_MemoryviewSlice_dsds_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_subspace_indices.memview)) __PYX_ERR(0, 11, __pyx_L3_error)
__pyx_v_smolyak_coeffs = values[2];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__pyx_fuse_0update_smolyak_coefficients_pyx", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.__pyx_fuse_0update_smolyak_coefficients_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_2__pyx_fuse_0update_smolyak_coefficients_pyx(__pyx_self, __pyx_v_new_index, __pyx_v_subspace_indices, __pyx_v_smolyak_coeffs);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_2__pyx_fuse_0update_smolyak_coefficients_pyx(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_new_index, __Pyx_memviewslice __pyx_v_subspace_indices, PyObject *__pyx_v_smolyak_coeffs) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_0update_smolyak_coefficients_pyx", 0);
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_v_new_index.memview)) { __Pyx_RaiseUnboundLocalError("new_index"); __PYX_ERR(0, 11, __pyx_L1_error) }
if (unlikely(!__pyx_v_subspace_indices.memview)) { __Pyx_RaiseUnboundLocalError("subspace_indices"); __PYX_ERR(0, 11, __pyx_L1_error) }
__pyx_t_1 = __pyx_fuse_0__pyx_f_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(__pyx_v_new_index, __pyx_v_subspace_indices, __pyx_v_smolyak_coeffs, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.__pyx_fuse_0update_smolyak_coefficients_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_new_index, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_subspace_indices, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_5__pyx_fuse_1update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_1update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_fuse_1__pyx_f_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(__Pyx_memviewslice __pyx_v_new_index, __Pyx_memviewslice __pyx_v_subspace_indices, PyObject *__pyx_v_smolyak_coeffs, CYTHON_UNUSED int __pyx_skip_dispatch) {
PyObject *__pyx_v_dtype = NULL;
__Pyx_memviewslice __pyx_v_smolyak_coeffs_view = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_v_ii;
int __pyx_v_jj;
int __pyx_v_num_vars;
int __pyx_v_num_subspace_indices;
__Pyx_memviewslice __pyx_v_diff = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_v_diff_sum;
int __pyx_v_update;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
__Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
__Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_t_7;
int __pyx_t_8;
int __pyx_t_9;
int __pyx_t_10;
int __pyx_t_11;
int __pyx_t_12;
Py_ssize_t __pyx_t_13;
Py_ssize_t __pyx_t_14;
Py_ssize_t __pyx_t_15;
Py_ssize_t __pyx_t_16;
int __pyx_t_17;
int __pyx_t_18;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_1update_smolyak_coefficients_pyx", 0);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":16
* dtype = np.int32
* if mixed_type is long:
* dtype = np.int64 # <<<<<<<<<<<<<<
*
* cdef double [:] smolyak_coeffs_view = smolyak_coeffs
*/
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_dtype = __pyx_t_2;
__pyx_t_2 = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":18
* dtype = np.int64
*
* cdef double [:] smolyak_coeffs_view = smolyak_coeffs # <<<<<<<<<<<<<<
*
* cdef int ii,jj
*/
__pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_smolyak_coeffs, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 18, __pyx_L1_error)
__pyx_v_smolyak_coeffs_view = __pyx_t_3;
__pyx_t_3.memview = NULL;
__pyx_t_3.data = NULL;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":21
*
* cdef int ii,jj
* cdef int num_vars = subspace_indices.shape[0] # <<<<<<<<<<<<<<
* cdef int num_subspace_indices = subspace_indices.shape[1]
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
*/
__pyx_v_num_vars = (__pyx_v_subspace_indices.shape[0]);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":22
* cdef int ii,jj
* cdef int num_vars = subspace_indices.shape[0]
* cdef int num_subspace_indices = subspace_indices.shape[1] # <<<<<<<<<<<<<<
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
* cdef int diff_sum = 0
*/
__pyx_v_num_subspace_indices = (__pyx_v_subspace_indices.shape[1]);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":23
* cdef int num_vars = subspace_indices.shape[0]
* cdef int num_subspace_indices = subspace_indices.shape[1]
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype) # <<<<<<<<<<<<<<
* cdef int diff_sum = 0
* update = True
*/
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_num_vars); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 23, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_diff = __pyx_t_6;
__pyx_t_6.memview = NULL;
__pyx_t_6.data = NULL;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":24
* cdef int num_subspace_indices = subspace_indices.shape[1]
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
* cdef int diff_sum = 0 # <<<<<<<<<<<<<<
* update = True
*
*/
__pyx_v_diff_sum = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":25
* cdef mixed_type [:] diff = np.empty((num_vars),dtype=dtype)
* cdef int diff_sum = 0
* update = True # <<<<<<<<<<<<<<
*
* for ii in range(num_subspace_indices):
*/
__pyx_v_update = 1;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":27
* update = True
*
* for ii in range(num_subspace_indices): # <<<<<<<<<<<<<<
* diff_sum = 0
* update = True
*/
__pyx_t_7 = __pyx_v_num_subspace_indices;
__pyx_t_8 = __pyx_t_7;
for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
__pyx_v_ii = __pyx_t_9;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":28
*
* for ii in range(num_subspace_indices):
* diff_sum = 0 # <<<<<<<<<<<<<<
* update = True
* for jj in range(num_vars):
*/
__pyx_v_diff_sum = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":29
* for ii in range(num_subspace_indices):
* diff_sum = 0
* update = True # <<<<<<<<<<<<<<
* for jj in range(num_vars):
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
*/
__pyx_v_update = 1;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":30
* diff_sum = 0
* update = True
* for jj in range(num_vars): # <<<<<<<<<<<<<<
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj]
*/
__pyx_t_10 = __pyx_v_num_vars;
__pyx_t_11 = __pyx_t_10;
for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
__pyx_v_jj = __pyx_t_12;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":31
* update = True
* for jj in range(num_vars):
* diff[jj] = new_index[jj]-subspace_indices[jj,ii] # <<<<<<<<<<<<<<
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1):
*/
__pyx_t_13 = __pyx_v_jj;
__pyx_t_14 = __pyx_v_jj;
__pyx_t_15 = __pyx_v_ii;
__pyx_t_16 = __pyx_v_jj;
*((long *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_16 * __pyx_v_diff.strides[0]) )) = ((*((long *) ( /* dim=0 */ (__pyx_v_new_index.data + __pyx_t_13 * __pyx_v_new_index.strides[0]) ))) - (*((long *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_subspace_indices.data + __pyx_t_14 * __pyx_v_subspace_indices.strides[0]) ) + __pyx_t_15 * __pyx_v_subspace_indices.strides[1]) ))));
/* "pyapprox/cython/adaptive_sparse_grid.pyx":32
* for jj in range(num_vars):
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj] # <<<<<<<<<<<<<<
* if (diff[jj]<0) or (diff[jj]>1):
* update = False
*/
__pyx_t_15 = __pyx_v_jj;
__pyx_v_diff_sum = (__pyx_v_diff_sum + (*((long *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_15 * __pyx_v_diff.strides[0]) ))));
/* "pyapprox/cython/adaptive_sparse_grid.pyx":33
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1): # <<<<<<<<<<<<<<
* update = False
* break
*/
__pyx_t_15 = __pyx_v_jj;
__pyx_t_18 = (((*((long *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_15 * __pyx_v_diff.strides[0]) ))) < 0) != 0);
if (!__pyx_t_18) {
} else {
__pyx_t_17 = __pyx_t_18;
goto __pyx_L8_bool_binop_done;
}
__pyx_t_15 = __pyx_v_jj;
__pyx_t_18 = (((*((long *) ( /* dim=0 */ (__pyx_v_diff.data + __pyx_t_15 * __pyx_v_diff.strides[0]) ))) > 1) != 0);
__pyx_t_17 = __pyx_t_18;
__pyx_L8_bool_binop_done:;
if (__pyx_t_17) {
/* "pyapprox/cython/adaptive_sparse_grid.pyx":34
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1):
* update = False # <<<<<<<<<<<<<<
* break
* if update:
*/
__pyx_v_update = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":35
* if (diff[jj]<0) or (diff[jj]>1):
* update = False
* break # <<<<<<<<<<<<<<
* if update:
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
*/
goto __pyx_L6_break;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":33
* diff[jj] = new_index[jj]-subspace_indices[jj,ii]
* diff_sum += diff[jj]
* if (diff[jj]<0) or (diff[jj]>1): # <<<<<<<<<<<<<<
* update = False
* break
*/
}
}
__pyx_L6_break:;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":36
* update = False
* break
* if update: # <<<<<<<<<<<<<<
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
* return smolyak_coeffs
*/
__pyx_t_17 = (__pyx_v_update != 0);
if (__pyx_t_17) {
/* "pyapprox/cython/adaptive_sparse_grid.pyx":37
* break
* if update:
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum # <<<<<<<<<<<<<<
* return smolyak_coeffs
*/
__pyx_t_15 = __pyx_v_ii;
*((double *) ( /* dim=0 */ (__pyx_v_smolyak_coeffs_view.data + __pyx_t_15 * __pyx_v_smolyak_coeffs_view.strides[0]) )) += pow(-1., ((double)__pyx_v_diff_sum));
/* "pyapprox/cython/adaptive_sparse_grid.pyx":36
* update = False
* break
* if update: # <<<<<<<<<<<<<<
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
* return smolyak_coeffs
*/
}
}
/* "pyapprox/cython/adaptive_sparse_grid.pyx":38
* if update:
* smolyak_coeffs_view[ii]+=(-1.)**diff_sum
* return smolyak_coeffs # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_smolyak_coeffs);
__pyx_r = __pyx_v_smolyak_coeffs;
goto __pyx_L0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":11
* @cython.boundscheck(False) # Deactivate bounds checking
* @cython.wraparound(False) # Deactivate negative indexing.
* cpdef update_smolyak_coefficients_pyx(mixed_type [:] new_index, mixed_type [:,:] subspace_indices, smolyak_coeffs): # <<<<<<<<<<<<<<
*
* if mixed_type is int:
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.update_smolyak_coefficients_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_dtype);
__PYX_XDEC_MEMVIEW(&__pyx_v_smolyak_coeffs_view, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_diff, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_5__pyx_fuse_1update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_fuse_1__pyx_mdef_8pyapprox_6cython_20adaptive_sparse_grid_5__pyx_fuse_1update_smolyak_coefficients_pyx = {"__pyx_fuse_1update_smolyak_coefficients_pyx", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_5__pyx_fuse_1update_smolyak_coefficients_pyx, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_8pyapprox_6cython_20adaptive_sparse_grid_5__pyx_fuse_1update_smolyak_coefficients_pyx(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_new_index = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_subspace_indices = { 0, 0, { 0 }, { 0 }, { 0 } };
PyObject *__pyx_v_smolyak_coeffs = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__pyx_fuse_1update_smolyak_coefficients_pyx (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_new_index,&__pyx_n_s_subspace_indices,&__pyx_n_s_smolyak_coeffs,0};
PyObject* values[3] = {0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new_index)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_subspace_indices)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fuse_1update_smolyak_coefficients_pyx", 1, 3, 3, 1); __PYX_ERR(0, 11, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_smolyak_coeffs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_fuse_1update_smolyak_coefficients_pyx", 1, 3, 3, 2); __PYX_ERR(0, 11, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_1update_smolyak_coefficients_pyx") < 0)) __PYX_ERR(0, 11, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
}
__pyx_v_new_index = __Pyx_PyObject_to_MemoryviewSlice_ds_long(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_new_index.memview)) __PYX_ERR(0, 11, __pyx_L3_error)
__pyx_v_subspace_indices = __Pyx_PyObject_to_MemoryviewSlice_dsds_long(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_subspace_indices.memview)) __PYX_ERR(0, 11, __pyx_L3_error)
__pyx_v_smolyak_coeffs = values[2];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__pyx_fuse_1update_smolyak_coefficients_pyx", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.__pyx_fuse_1update_smolyak_coefficients_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_4__pyx_fuse_1update_smolyak_coefficients_pyx(__pyx_self, __pyx_v_new_index, __pyx_v_subspace_indices, __pyx_v_smolyak_coeffs);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8pyapprox_6cython_20adaptive_sparse_grid_4__pyx_fuse_1update_smolyak_coefficients_pyx(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_new_index, __Pyx_memviewslice __pyx_v_subspace_indices, PyObject *__pyx_v_smolyak_coeffs) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_fuse_1update_smolyak_coefficients_pyx", 0);
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_v_new_index.memview)) { __Pyx_RaiseUnboundLocalError("new_index"); __PYX_ERR(0, 11, __pyx_L1_error) }
if (unlikely(!__pyx_v_subspace_indices.memview)) { __Pyx_RaiseUnboundLocalError("subspace_indices"); __PYX_ERR(0, 11, __pyx_L1_error) }
__pyx_t_1 = __pyx_fuse_1__pyx_f_8pyapprox_6cython_20adaptive_sparse_grid_update_smolyak_coefficients_pyx(__pyx_v_new_index, __pyx_v_subspace_indices, __pyx_v_smolyak_coeffs, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("pyapprox.cython.adaptive_sparse_grid.__pyx_fuse_1update_smolyak_coefficients_pyx", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_new_index, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_subspace_indices, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":122
* cdef bint dtype_is_object
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
* mode="c", bint allocate_buffer=True):
*
*/
/* Python wrapper */
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_shape = 0;
Py_ssize_t __pyx_v_itemsize;
PyObject *__pyx_v_format = 0;
PyObject *__pyx_v_mode = 0;
int __pyx_v_allocate_buffer;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0};
PyObject* values[5] = {0,0,0,0,0};
values[3] = ((PyObject *)__pyx_n_s_c);
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(1, 122, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(1, 122, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
if (value) { values[3] = value; kw_args--; }
}
CYTHON_FALLTHROUGH;
case 4:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer);
if (value) { values[4] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 122, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_shape = ((PyObject*)values[0]);
__pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 122, __pyx_L3_error)
__pyx_v_format = values[2];
__pyx_v_mode = values[3];
if (values[4]) {
__pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 123, __pyx_L3_error)
} else {
/* "View.MemoryView":123
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
* mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<<
*
* cdef int idx
*/
__pyx_v_allocate_buffer = ((int)1);
}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 122, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(1, 122, __pyx_L1_error)
if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(1, 122, __pyx_L1_error)
}
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer);
/* "View.MemoryView":122
* cdef bint dtype_is_object
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
* mode="c", bint allocate_buffer=True):
*
*/
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) {
int __pyx_v_idx;
Py_ssize_t __pyx_v_i;
Py_ssize_t __pyx_v_dim;
PyObject **__pyx_v_p;
char __pyx_v_order;
int __pyx_r;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
char *__pyx_t_7;
int __pyx_t_8;
Py_ssize_t __pyx_t_9;
PyObject *__pyx_t_10 = NULL;
Py_ssize_t __pyx_t_11;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
__Pyx_INCREF(__pyx_v_format);
/* "View.MemoryView":129
* cdef PyObject **p
*
* self.ndim = <int> len(shape) # <<<<<<<<<<<<<<
* self.itemsize = itemsize
*
*/
if (unlikely(__pyx_v_shape == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(1, 129, __pyx_L1_error)
}
__pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 129, __pyx_L1_error)
__pyx_v_self->ndim = ((int)__pyx_t_1);
/* "View.MemoryView":130
*
* self.ndim = <int> len(shape)
* self.itemsize = itemsize # <<<<<<<<<<<<<<
*
* if not self.ndim:
*/
__pyx_v_self->itemsize = __pyx_v_itemsize;
/* "View.MemoryView":132
* self.itemsize = itemsize
*
* if not self.ndim: # <<<<<<<<<<<<<<
* raise ValueError("Empty shape tuple for cython.array")
*
*/
__pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
if (unlikely(__pyx_t_2)) {
/* "View.MemoryView":133
*
* if not self.ndim:
* raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<<
*
* if itemsize <= 0:
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 133, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 133, __pyx_L1_error)
/* "View.MemoryView":132
* self.itemsize = itemsize
*
* if not self.ndim: # <<<<<<<<<<<<<<
* raise ValueError("Empty shape tuple for cython.array")
*
*/
}
/* "View.MemoryView":135
* raise ValueError("Empty shape tuple for cython.array")
*
* if itemsize <= 0: # <<<<<<<<<<<<<<
* raise ValueError("itemsize <= 0 for cython.array")
*
*/
__pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
if (unlikely(__pyx_t_2)) {
/* "View.MemoryView":136
*
* if itemsize <= 0:
* raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<<
*
* if not isinstance(format, bytes):
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 136, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 136, __pyx_L1_error)
/* "View.MemoryView":135
* raise ValueError("Empty shape tuple for cython.array")
*
* if itemsize <= 0: # <<<<<<<<<<<<<<
* raise ValueError("itemsize <= 0 for cython.array")
*
*/
}
/* "View.MemoryView":138
* raise ValueError("itemsize <= 0 for cython.array")
*
* if not isinstance(format, bytes): # <<<<<<<<<<<<<<
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string
*/
__pyx_t_2 = PyBytes_Check(__pyx_v_format);
__pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":139
*
* if not isinstance(format, bytes):
* format = format.encode('ASCII') # <<<<<<<<<<<<<<
* self._format = format # keep a reference to the byte string
* self.format = self._format
*/
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 139, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
if (likely(__pyx_t_6)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_5, function);
}
}
__pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ASCII) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ASCII);
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 139, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":138
* raise ValueError("itemsize <= 0 for cython.array")
*
* if not isinstance(format, bytes): # <<<<<<<<<<<<<<
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string
*/
}
/* "View.MemoryView":140
* if not isinstance(format, bytes):
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<<
* self.format = self._format
*
*/
if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(1, 140, __pyx_L1_error)
__pyx_t_3 = __pyx_v_format;
__Pyx_INCREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__Pyx_GOTREF(__pyx_v_self->_format);
__Pyx_DECREF(__pyx_v_self->_format);
__pyx_v_self->_format = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":141
* format = format.encode('ASCII')
* self._format = format # keep a reference to the byte string
* self.format = self._format # <<<<<<<<<<<<<<
*
*
*/
if (unlikely(__pyx_v_self->_format == Py_None)) {
PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
__PYX_ERR(1, 141, __pyx_L1_error)
}
__pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(1, 141, __pyx_L1_error)
__pyx_v_self->format = __pyx_t_7;
/* "View.MemoryView":144
*
*
* self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<<
* self._strides = self._shape + self.ndim
*
*/
__pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
/* "View.MemoryView":145
*
* self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
* self._strides = self._shape + self.ndim # <<<<<<<<<<<<<<
*
* if not self._shape:
*/
__pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
/* "View.MemoryView":147
* self._strides = self._shape + self.ndim
*
* if not self._shape: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate shape and strides.")
*
*/
__pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
if (unlikely(__pyx_t_4)) {
/* "View.MemoryView":148
*
* if not self._shape:
* raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 148, __pyx_L1_error)
/* "View.MemoryView":147
* self._strides = self._shape + self.ndim
*
* if not self._shape: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate shape and strides.")
*
*/
}
/* "View.MemoryView":151
*
*
* for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
*/
__pyx_t_8 = 0;
__pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
for (;;) {
if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 151, __pyx_L1_error)
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 151, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
#endif
__pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 151, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_dim = __pyx_t_9;
__pyx_v_idx = __pyx_t_8;
__pyx_t_8 = (__pyx_t_8 + 1);
/* "View.MemoryView":152
*
* for idx, dim in enumerate(shape):
* if dim <= 0: # <<<<<<<<<<<<<<
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
* self._shape[idx] = dim
*/
__pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
if (unlikely(__pyx_t_4)) {
/* "View.MemoryView":153
* for idx, dim in enumerate(shape):
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<<
* self._shape[idx] = dim
*
*/
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
__pyx_t_5 = 0;
__pyx_t_6 = 0;
__pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_Raise(__pyx_t_10, 0, 0, 0);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__PYX_ERR(1, 153, __pyx_L1_error)
/* "View.MemoryView":152
*
* for idx, dim in enumerate(shape):
* if dim <= 0: # <<<<<<<<<<<<<<
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
* self._shape[idx] = dim
*/
}
/* "View.MemoryView":154
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
* self._shape[idx] = dim # <<<<<<<<<<<<<<
*
* cdef char order
*/
(__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
/* "View.MemoryView":151
*
*
* for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
* if dim <= 0:
* raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
*/
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":157
*
* cdef char order
* if mode == 'fortran': # <<<<<<<<<<<<<<
* order = b'F'
* self.mode = u'fortran'
*/
__pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 157, __pyx_L1_error)
if (__pyx_t_4) {
/* "View.MemoryView":158
* cdef char order
* if mode == 'fortran':
* order = b'F' # <<<<<<<<<<<<<<
* self.mode = u'fortran'
* elif mode == 'c':
*/
__pyx_v_order = 'F';
/* "View.MemoryView":159
* if mode == 'fortran':
* order = b'F'
* self.mode = u'fortran' # <<<<<<<<<<<<<<
* elif mode == 'c':
* order = b'C'
*/
__Pyx_INCREF(__pyx_n_u_fortran);
__Pyx_GIVEREF(__pyx_n_u_fortran);
__Pyx_GOTREF(__pyx_v_self->mode);
__Pyx_DECREF(__pyx_v_self->mode);
__pyx_v_self->mode = __pyx_n_u_fortran;
/* "View.MemoryView":157
*
* cdef char order
* if mode == 'fortran': # <<<<<<<<<<<<<<
* order = b'F'
* self.mode = u'fortran'
*/
goto __pyx_L10;
}
/* "View.MemoryView":160
* order = b'F'
* self.mode = u'fortran'
* elif mode == 'c': # <<<<<<<<<<<<<<
* order = b'C'
* self.mode = u'c'
*/
__pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 160, __pyx_L1_error)
if (likely(__pyx_t_4)) {
/* "View.MemoryView":161
* self.mode = u'fortran'
* elif mode == 'c':
* order = b'C' # <<<<<<<<<<<<<<
* self.mode = u'c'
* else:
*/
__pyx_v_order = 'C';
/* "View.MemoryView":162
* elif mode == 'c':
* order = b'C'
* self.mode = u'c' # <<<<<<<<<<<<<<
* else:
* raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
*/
__Pyx_INCREF(__pyx_n_u_c);
__Pyx_GIVEREF(__pyx_n_u_c);
__Pyx_GOTREF(__pyx_v_self->mode);
__Pyx_DECREF(__pyx_v_self->mode);
__pyx_v_self->mode = __pyx_n_u_c;
/* "View.MemoryView":160
* order = b'F'
* self.mode = u'fortran'
* elif mode == 'c': # <<<<<<<<<<<<<<
* order = b'C'
* self.mode = u'c'
*/
goto __pyx_L10;
}
/* "View.MemoryView":164
* self.mode = u'c'
* else:
* raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<<
*
* self.len = fill_contig_strides_array(self._shape, self._strides,
*/
/*else*/ {
__pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 164, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 164, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_10, 0, 0, 0);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__PYX_ERR(1, 164, __pyx_L1_error)
}
__pyx_L10:;
/* "View.MemoryView":166
* raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
*
* self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<<
* itemsize, self.ndim, order)
*
*/
__pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order);
/* "View.MemoryView":169
* itemsize, self.ndim, order)
*
* self.free_data = allocate_buffer # <<<<<<<<<<<<<<
* self.dtype_is_object = format == b'O'
* if allocate_buffer:
*/
__pyx_v_self->free_data = __pyx_v_allocate_buffer;
/* "View.MemoryView":170
*
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<<
* if allocate_buffer:
*
*/
__pyx_t_10 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 170, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 170, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__pyx_v_self->dtype_is_object = __pyx_t_4;
/* "View.MemoryView":171
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O'
* if allocate_buffer: # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_4 = (__pyx_v_allocate_buffer != 0);
if (__pyx_t_4) {
/* "View.MemoryView":174
*
*
* self.data = <char *>malloc(self.len) # <<<<<<<<<<<<<<
* if not self.data:
* raise MemoryError("unable to allocate array data.")
*/
__pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
/* "View.MemoryView":175
*
* self.data = <char *>malloc(self.len)
* if not self.data: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate array data.")
*
*/
__pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
if (unlikely(__pyx_t_4)) {
/* "View.MemoryView":176
* self.data = <char *>malloc(self.len)
* if not self.data:
* raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
*
* if self.dtype_is_object:
*/
__pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 176, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_Raise(__pyx_t_10, 0, 0, 0);
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
__PYX_ERR(1, 176, __pyx_L1_error)
/* "View.MemoryView":175
*
* self.data = <char *>malloc(self.len)
* if not self.data: # <<<<<<<<<<<<<<
* raise MemoryError("unable to allocate array data.")
*
*/
}
/* "View.MemoryView":178
* raise MemoryError("unable to allocate array data.")
*
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* p = <PyObject **> self.data
* for i in range(self.len / itemsize):
*/
__pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
if (__pyx_t_4) {
/* "View.MemoryView":179
*
* if self.dtype_is_object:
* p = <PyObject **> self.data # <<<<<<<<<<<<<<
* for i in range(self.len / itemsize):
* p[i] = Py_None
*/
__pyx_v_p = ((PyObject **)__pyx_v_self->data);
/* "View.MemoryView":180
* if self.dtype_is_object:
* p = <PyObject **> self.data
* for i in range(self.len / itemsize): # <<<<<<<<<<<<<<
* p[i] = Py_None
* Py_INCREF(Py_None)
*/
if (unlikely(__pyx_v_itemsize == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
__PYX_ERR(1, 180, __pyx_L1_error)
}
else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) {
PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
__PYX_ERR(1, 180, __pyx_L1_error)
}
__pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
__pyx_t_9 = __pyx_t_1;
for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
__pyx_v_i = __pyx_t_11;
/* "View.MemoryView":181
* p = <PyObject **> self.data
* for i in range(self.len / itemsize):
* p[i] = Py_None # <<<<<<<<<<<<<<
* Py_INCREF(Py_None)
*
*/
(__pyx_v_p[__pyx_v_i]) = Py_None;
/* "View.MemoryView":182
* for i in range(self.len / itemsize):
* p[i] = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
Py_INCREF(Py_None);
}
/* "View.MemoryView":178
* raise MemoryError("unable to allocate array data.")
*
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* p = <PyObject **> self.data
* for i in range(self.len / itemsize):
*/
}
/* "View.MemoryView":171
* self.free_data = allocate_buffer
* self.dtype_is_object = format == b'O'
* if allocate_buffer: # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":122
* cdef bint dtype_is_object
*
* def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
* mode="c", bint allocate_buffer=True):
*
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_format);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":185
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* cdef int bufmode = -1
* if self.mode == u"c":
*/
/* Python wrapper */
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_v_bufmode;
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
char *__pyx_t_4;
Py_ssize_t __pyx_t_5;
int __pyx_t_6;
Py_ssize_t *__pyx_t_7;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
if (__pyx_v_info == NULL) {
PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
return -1;
}
__Pyx_RefNannySetupContext("__getbuffer__", 0);
__pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
__Pyx_GIVEREF(__pyx_v_info->obj);
/* "View.MemoryView":186
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* cdef int bufmode = -1 # <<<<<<<<<<<<<<
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
*/
__pyx_v_bufmode = -1;
/* "View.MemoryView":187
* def __getbuffer__(self, Py_buffer *info, int flags):
* cdef int bufmode = -1
* if self.mode == u"c": # <<<<<<<<<<<<<<
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran":
*/
__pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 187, __pyx_L1_error)
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":188
* cdef int bufmode = -1
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<<
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
*/
__pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
/* "View.MemoryView":187
* def __getbuffer__(self, Py_buffer *info, int flags):
* cdef int bufmode = -1
* if self.mode == u"c": # <<<<<<<<<<<<<<
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran":
*/
goto __pyx_L3;
}
/* "View.MemoryView":189
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran": # <<<<<<<<<<<<<<
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
*/
__pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 189, __pyx_L1_error)
__pyx_t_1 = (__pyx_t_2 != 0);
if (__pyx_t_1) {
/* "View.MemoryView":190
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<<
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.")
*/
__pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
/* "View.MemoryView":189
* if self.mode == u"c":
* bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* elif self.mode == u"fortran": # <<<<<<<<<<<<<<
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
*/
}
__pyx_L3:;
/* "View.MemoryView":191
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode): # <<<<<<<<<<<<<<
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data
*/
__pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":192
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<<
* info.buf = self.data
* info.len = self.len
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 192, __pyx_L1_error)
/* "View.MemoryView":191
* elif self.mode == u"fortran":
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode): # <<<<<<<<<<<<<<
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data
*/
}
/* "View.MemoryView":193
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data # <<<<<<<<<<<<<<
* info.len = self.len
* info.ndim = self.ndim
*/
__pyx_t_4 = __pyx_v_self->data;
__pyx_v_info->buf = __pyx_t_4;
/* "View.MemoryView":194
* raise ValueError("Can only create a buffer that is contiguous in memory.")
* info.buf = self.data
* info.len = self.len # <<<<<<<<<<<<<<
* info.ndim = self.ndim
* info.shape = self._shape
*/
__pyx_t_5 = __pyx_v_self->len;
__pyx_v_info->len = __pyx_t_5;
/* "View.MemoryView":195
* info.buf = self.data
* info.len = self.len
* info.ndim = self.ndim # <<<<<<<<<<<<<<
* info.shape = self._shape
* info.strides = self._strides
*/
__pyx_t_6 = __pyx_v_self->ndim;
__pyx_v_info->ndim = __pyx_t_6;
/* "View.MemoryView":196
* info.len = self.len
* info.ndim = self.ndim
* info.shape = self._shape # <<<<<<<<<<<<<<
* info.strides = self._strides
* info.suboffsets = NULL
*/
__pyx_t_7 = __pyx_v_self->_shape;
__pyx_v_info->shape = __pyx_t_7;
/* "View.MemoryView":197
* info.ndim = self.ndim
* info.shape = self._shape
* info.strides = self._strides # <<<<<<<<<<<<<<
* info.suboffsets = NULL
* info.itemsize = self.itemsize
*/
__pyx_t_7 = __pyx_v_self->_strides;
__pyx_v_info->strides = __pyx_t_7;
/* "View.MemoryView":198
* info.shape = self._shape
* info.strides = self._strides
* info.suboffsets = NULL # <<<<<<<<<<<<<<
* info.itemsize = self.itemsize
* info.readonly = 0
*/
__pyx_v_info->suboffsets = NULL;
/* "View.MemoryView":199
* info.strides = self._strides
* info.suboffsets = NULL
* info.itemsize = self.itemsize # <<<<<<<<<<<<<<
* info.readonly = 0
*
*/
__pyx_t_5 = __pyx_v_self->itemsize;
__pyx_v_info->itemsize = __pyx_t_5;
/* "View.MemoryView":200
* info.suboffsets = NULL
* info.itemsize = self.itemsize
* info.readonly = 0 # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
__pyx_v_info->readonly = 0;
/* "View.MemoryView":202
* info.readonly = 0
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.format
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":203
*
* if flags & PyBUF_FORMAT:
* info.format = self.format # <<<<<<<<<<<<<<
* else:
* info.format = NULL
*/
__pyx_t_4 = __pyx_v_self->format;
__pyx_v_info->format = __pyx_t_4;
/* "View.MemoryView":202
* info.readonly = 0
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.format
* else:
*/
goto __pyx_L5;
}
/* "View.MemoryView":205
* info.format = self.format
* else:
* info.format = NULL # <<<<<<<<<<<<<<
*
* info.obj = self
*/
/*else*/ {
__pyx_v_info->format = NULL;
}
__pyx_L5:;
/* "View.MemoryView":207
* info.format = NULL
*
* info.obj = self # <<<<<<<<<<<<<<
*
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
*/
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj);
__pyx_v_info->obj = ((PyObject *)__pyx_v_self);
/* "View.MemoryView":185
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* cdef int bufmode = -1
* if self.mode == u"c":
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
if (__pyx_v_info->obj != NULL) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
goto __pyx_L2;
__pyx_L0:;
if (__pyx_v_info->obj == Py_None) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
__pyx_L2:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":211
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
*
* def __dealloc__(array self): # <<<<<<<<<<<<<<
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
*/
/* Python wrapper */
static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
}
static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
__Pyx_RefNannyDeclarations
int __pyx_t_1;
__Pyx_RefNannySetupContext("__dealloc__", 0);
/* "View.MemoryView":212
*
* def __dealloc__(array self):
* if self.callback_free_data != NULL: # <<<<<<<<<<<<<<
* self.callback_free_data(self.data)
* elif self.free_data:
*/
__pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":213
* def __dealloc__(array self):
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data) # <<<<<<<<<<<<<<
* elif self.free_data:
* if self.dtype_is_object:
*/
__pyx_v_self->callback_free_data(__pyx_v_self->data);
/* "View.MemoryView":212
*
* def __dealloc__(array self):
* if self.callback_free_data != NULL: # <<<<<<<<<<<<<<
* self.callback_free_data(self.data)
* elif self.free_data:
*/
goto __pyx_L3;
}
/* "View.MemoryView":214
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
* elif self.free_data: # <<<<<<<<<<<<<<
* if self.dtype_is_object:
* refcount_objects_in_slice(self.data, self._shape,
*/
__pyx_t_1 = (__pyx_v_self->free_data != 0);
if (__pyx_t_1) {
/* "View.MemoryView":215
* self.callback_free_data(self.data)
* elif self.free_data:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice(self.data, self._shape,
* self._strides, self.ndim, False)
*/
__pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
if (__pyx_t_1) {
/* "View.MemoryView":216
* elif self.free_data:
* if self.dtype_is_object:
* refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<<
* self._strides, self.ndim, False)
* free(self.data)
*/
__pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
/* "View.MemoryView":215
* self.callback_free_data(self.data)
* elif self.free_data:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice(self.data, self._shape,
* self._strides, self.ndim, False)
*/
}
/* "View.MemoryView":218
* refcount_objects_in_slice(self.data, self._shape,
* self._strides, self.ndim, False)
* free(self.data) # <<<<<<<<<<<<<<
* PyObject_Free(self._shape)
*
*/
free(__pyx_v_self->data);
/* "View.MemoryView":214
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
* elif self.free_data: # <<<<<<<<<<<<<<
* if self.dtype_is_object:
* refcount_objects_in_slice(self.data, self._shape,
*/
}
__pyx_L3:;
/* "View.MemoryView":219
* self._strides, self.ndim, False)
* free(self.data)
* PyObject_Free(self._shape) # <<<<<<<<<<<<<<
*
* @property
*/
PyObject_Free(__pyx_v_self->_shape);
/* "View.MemoryView":211
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
*
* def __dealloc__(array self): # <<<<<<<<<<<<<<
* if self.callback_free_data != NULL:
* self.callback_free_data(self.data)
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":222
*
* @property
* def memview(self): # <<<<<<<<<<<<<<
* return self.get_memview()
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":223
* @property
* def memview(self):
* return self.get_memview() # <<<<<<<<<<<<<<
*
* @cname('get_memview')
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 223, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":222
*
* @property
* def memview(self): # <<<<<<<<<<<<<<
* return self.get_memview()
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":226
*
* @cname('get_memview')
* cdef get_memview(self): # <<<<<<<<<<<<<<
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
* return memoryview(self, flags, self.dtype_is_object)
*/
static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
int __pyx_v_flags;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("get_memview", 0);
/* "View.MemoryView":227
* @cname('get_memview')
* cdef get_memview(self):
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<<
* return memoryview(self, flags, self.dtype_is_object)
*
*/
__pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
/* "View.MemoryView":228
* cdef get_memview(self):
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
* return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<<
*
* def __len__(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 228, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":226
*
* @cname('get_memview')
* cdef get_memview(self): # <<<<<<<<<<<<<<
* flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
* return memoryview(self, flags, self.dtype_is_object)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":230
* return memoryview(self, flags, self.dtype_is_object)
*
* def __len__(self): # <<<<<<<<<<<<<<
* return self._shape[0]
*
*/
/* Python wrapper */
static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__", 0);
/* "View.MemoryView":231
*
* def __len__(self):
* return self._shape[0] # <<<<<<<<<<<<<<
*
* def __getattr__(self, attr):
*/
__pyx_r = (__pyx_v_self->_shape[0]);
goto __pyx_L0;
/* "View.MemoryView":230
* return memoryview(self, flags, self.dtype_is_object)
*
* def __len__(self): # <<<<<<<<<<<<<<
* return self._shape[0]
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":233
* return self._shape[0]
*
* def __getattr__(self, attr): # <<<<<<<<<<<<<<
* return getattr(self.memview, attr)
*
*/
/* Python wrapper */
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getattr__", 0);
/* "View.MemoryView":234
*
* def __getattr__(self, attr):
* return getattr(self.memview, attr) # <<<<<<<<<<<<<<
*
* def __getitem__(self, item):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 234, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 234, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":233
* return self._shape[0]
*
* def __getattr__(self, attr): # <<<<<<<<<<<<<<
* return getattr(self.memview, attr)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":236
* return getattr(self.memview, attr)
*
* def __getitem__(self, item): # <<<<<<<<<<<<<<
* return self.memview[item]
*
*/
/* Python wrapper */
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
/* "View.MemoryView":237
*
* def __getitem__(self, item):
* return self.memview[item] # <<<<<<<<<<<<<<
*
* def __setitem__(self, item, value):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":236
* return getattr(self.memview, attr)
*
* def __getitem__(self, item): # <<<<<<<<<<<<<<
* return self.memview[item]
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":239
* return self.memview[item]
*
* def __setitem__(self, item, value): # <<<<<<<<<<<<<<
* self.memview[item] = value
*
*/
/* Python wrapper */
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
__pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
/* "View.MemoryView":240
*
* def __setitem__(self, item, value):
* self.memview[item] = value # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(1, 240, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "View.MemoryView":239
* return self.memview[item]
*
* def __setitem__(self, item, value): # <<<<<<<<<<<<<<
* self.memview[item] = value
*
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 2, __pyx_L1_error)
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 4, __pyx_L1_error)
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":244
*
* @cname("__pyx_array_new")
* cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<<
* char *mode, char *buf):
* cdef array result
*/
static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) {
struct __pyx_array_obj *__pyx_v_result = 0;
struct __pyx_array_obj *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("array_cwrapper", 0);
/* "View.MemoryView":248
* cdef array result
*
* if buf == NULL: # <<<<<<<<<<<<<<
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
*/
__pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":249
*
* if buf == NULL:
* result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<<
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'),
*/
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_INCREF(__pyx_v_shape);
__Pyx_GIVEREF(__pyx_v_shape);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
__pyx_t_2 = 0;
__pyx_t_3 = 0;
__pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
__pyx_t_4 = 0;
/* "View.MemoryView":248
* cdef array result
*
* if buf == NULL: # <<<<<<<<<<<<<<
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":251
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<<
* allocate_buffer=False)
* result.data = buf
*/
/*else*/ {
__pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_v_shape);
__Pyx_GIVEREF(__pyx_v_shape);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
__pyx_t_4 = 0;
__pyx_t_5 = 0;
__pyx_t_3 = 0;
/* "View.MemoryView":252
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'),
* allocate_buffer=False) # <<<<<<<<<<<<<<
* result.data = buf
*
*/
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(1, 252, __pyx_L1_error)
/* "View.MemoryView":251
* result = array(shape, itemsize, format, mode.decode('ASCII'))
* else:
* result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<<
* allocate_buffer=False)
* result.data = buf
*/
__pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
__pyx_t_5 = 0;
/* "View.MemoryView":253
* result = array(shape, itemsize, format, mode.decode('ASCII'),
* allocate_buffer=False)
* result.data = buf # <<<<<<<<<<<<<<
*
* return result
*/
__pyx_v_result->data = __pyx_v_buf;
}
__pyx_L3:;
/* "View.MemoryView":255
* result.data = buf
*
* return result # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = __pyx_v_result;
goto __pyx_L0;
/* "View.MemoryView":244
*
* @cname("__pyx_array_new")
* cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<<
* char *mode, char *buf):
* cdef array result
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":281
* cdef class Enum(object):
* cdef object name
* def __init__(self, name): # <<<<<<<<<<<<<<
* self.name = name
* def __repr__(self):
*/
/* Python wrapper */
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_name = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
PyObject* values[1] = {0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 281, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
}
__pyx_v_name = values[0];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 281, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__", 0);
/* "View.MemoryView":282
* cdef object name
* def __init__(self, name):
* self.name = name # <<<<<<<<<<<<<<
* def __repr__(self):
* return self.name
*/
__Pyx_INCREF(__pyx_v_name);
__Pyx_GIVEREF(__pyx_v_name);
__Pyx_GOTREF(__pyx_v_self->name);
__Pyx_DECREF(__pyx_v_self->name);
__pyx_v_self->name = __pyx_v_name;
/* "View.MemoryView":281
* cdef class Enum(object):
* cdef object name
* def __init__(self, name): # <<<<<<<<<<<<<<
* self.name = name
* def __repr__(self):
*/
/* function exit code */
__pyx_r = 0;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":283
* def __init__(self, name):
* self.name = name
* def __repr__(self): # <<<<<<<<<<<<<<
* return self.name
*
*/
/* Python wrapper */
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
__pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__repr__", 0);
/* "View.MemoryView":284
* self.name = name
* def __repr__(self):
* return self.name # <<<<<<<<<<<<<<
*
* cdef generic = Enum("<strided and direct or indirect>")
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->name);
__pyx_r = __pyx_v_self->name;
goto __pyx_L0;
/* "View.MemoryView":283
* def __init__(self, name):
* self.name = name
* def __repr__(self): # <<<<<<<<<<<<<<
* return self.name
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* cdef tuple state
* cdef object _dict
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
PyObject *__pyx_v_state = 0;
PyObject *__pyx_v__dict = 0;
int __pyx_v_use_setstate;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_t_3;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":5
* cdef object _dict
* cdef bint use_setstate
* state = (self.name,) # <<<<<<<<<<<<<<
* _dict = getattr(self, '__dict__', None)
* if _dict is not None:
*/
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_self->name);
__Pyx_GIVEREF(__pyx_v_self->name);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
__pyx_v_state = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
/* "(tree fragment)":6
* cdef bint use_setstate
* state = (self.name,)
* _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
* if _dict is not None:
* state += (_dict,)
*/
__pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v__dict = __pyx_t_1;
__pyx_t_1 = 0;
/* "(tree fragment)":7
* state = (self.name,)
* _dict = getattr(self, '__dict__', None)
* if _dict is not None: # <<<<<<<<<<<<<<
* state += (_dict,)
* use_setstate = True
*/
__pyx_t_2 = (__pyx_v__dict != Py_None);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
/* "(tree fragment)":8
* _dict = getattr(self, '__dict__', None)
* if _dict is not None:
* state += (_dict,) # <<<<<<<<<<<<<<
* use_setstate = True
* else:
*/
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v__dict);
__Pyx_GIVEREF(__pyx_v__dict);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
__pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
__pyx_t_4 = 0;
/* "(tree fragment)":9
* if _dict is not None:
* state += (_dict,)
* use_setstate = True # <<<<<<<<<<<<<<
* else:
* use_setstate = self.name is not None
*/
__pyx_v_use_setstate = 1;
/* "(tree fragment)":7
* state = (self.name,)
* _dict = getattr(self, '__dict__', None)
* if _dict is not None: # <<<<<<<<<<<<<<
* state += (_dict,)
* use_setstate = True
*/
goto __pyx_L3;
}
/* "(tree fragment)":11
* use_setstate = True
* else:
* use_setstate = self.name is not None # <<<<<<<<<<<<<<
* if use_setstate:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
*/
/*else*/ {
__pyx_t_3 = (__pyx_v_self->name != Py_None);
__pyx_v_use_setstate = __pyx_t_3;
}
__pyx_L3:;
/* "(tree fragment)":12
* else:
* use_setstate = self.name is not None
* if use_setstate: # <<<<<<<<<<<<<<
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
* else:
*/
__pyx_t_3 = (__pyx_v_use_setstate != 0);
if (__pyx_t_3) {
/* "(tree fragment)":13
* use_setstate = self.name is not None
* if use_setstate:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state # <<<<<<<<<<<<<<
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_INCREF(__pyx_int_184977713);
__Pyx_GIVEREF(__pyx_int_184977713);
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
__pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
__Pyx_INCREF(__pyx_v_state);
__Pyx_GIVEREF(__pyx_v_state);
PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
__pyx_t_4 = 0;
__pyx_t_1 = 0;
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
/* "(tree fragment)":12
* else:
* use_setstate = self.name is not None
* if use_setstate: # <<<<<<<<<<<<<<
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
* else:
*/
}
/* "(tree fragment)":15
* return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state) # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* __pyx_unpickle_Enum__set_state(self, __pyx_state)
*/
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
__Pyx_INCREF(__pyx_int_184977713);
__Pyx_GIVEREF(__pyx_int_184977713);
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
__Pyx_INCREF(__pyx_v_state);
__Pyx_GIVEREF(__pyx_v_state);
PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
__pyx_t_5 = 0;
__pyx_t_1 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* cdef tuple state
* cdef object _dict
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_state);
__Pyx_XDECREF(__pyx_v__dict);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":16
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(self, __pyx_state)
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":17
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
* def __setstate_cython__(self, __pyx_state):
* __pyx_unpickle_Enum__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
*/
if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
__pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "(tree fragment)":16
* else:
* return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(self, __pyx_state)
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":298
*
* @cname('__pyx_align_pointer')
* cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<<
* "Align pointer memory on a given boundary"
* cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
*/
static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
Py_intptr_t __pyx_v_aligned_p;
size_t __pyx_v_offset;
void *__pyx_r;
int __pyx_t_1;
/* "View.MemoryView":300
* cdef void *align_pointer(void *memory, size_t alignment) nogil:
* "Align pointer memory on a given boundary"
* cdef Py_intptr_t aligned_p = <Py_intptr_t> memory # <<<<<<<<<<<<<<
* cdef size_t offset
*
*/
__pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
/* "View.MemoryView":304
*
* with cython.cdivision(True):
* offset = aligned_p % alignment # <<<<<<<<<<<<<<
*
* if offset > 0:
*/
__pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
/* "View.MemoryView":306
* offset = aligned_p % alignment
*
* if offset > 0: # <<<<<<<<<<<<<<
* aligned_p += alignment - offset
*
*/
__pyx_t_1 = ((__pyx_v_offset > 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":307
*
* if offset > 0:
* aligned_p += alignment - offset # <<<<<<<<<<<<<<
*
* return <void *> aligned_p
*/
__pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
/* "View.MemoryView":306
* offset = aligned_p % alignment
*
* if offset > 0: # <<<<<<<<<<<<<<
* aligned_p += alignment - offset
*
*/
}
/* "View.MemoryView":309
* aligned_p += alignment - offset
*
* return <void *> aligned_p # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = ((void *)__pyx_v_aligned_p);
goto __pyx_L0;
/* "View.MemoryView":298
*
* @cname('__pyx_align_pointer')
* cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<<
* "Align pointer memory on a given boundary"
* cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":345
* cdef __Pyx_TypeInfo *typeinfo
*
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<<
* self.obj = obj
* self.flags = flags
*/
/* Python wrapper */
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_obj = 0;
int __pyx_v_flags;
int __pyx_v_dtype_is_object;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
PyObject* values[3] = {0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(1, 345, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object);
if (value) { values[2] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 345, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_obj = values[0];
__pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error)
if (values[2]) {
__pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error)
} else {
__pyx_v_dtype_is_object = ((int)0);
}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 345, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
/* "View.MemoryView":346
*
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
* self.obj = obj # <<<<<<<<<<<<<<
* self.flags = flags
* if type(self) is memoryview or obj is not None:
*/
__Pyx_INCREF(__pyx_v_obj);
__Pyx_GIVEREF(__pyx_v_obj);
__Pyx_GOTREF(__pyx_v_self->obj);
__Pyx_DECREF(__pyx_v_self->obj);
__pyx_v_self->obj = __pyx_v_obj;
/* "View.MemoryView":347
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
* self.obj = obj
* self.flags = flags # <<<<<<<<<<<<<<
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags)
*/
__pyx_v_self->flags = __pyx_v_flags;
/* "View.MemoryView":348
* self.obj = obj
* self.flags = flags
* if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<<
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL:
*/
__pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
__pyx_t_3 = (__pyx_t_2 != 0);
if (!__pyx_t_3) {
} else {
__pyx_t_1 = __pyx_t_3;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_3 = (__pyx_v_obj != Py_None);
__pyx_t_2 = (__pyx_t_3 != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L4_bool_binop_done:;
if (__pyx_t_1) {
/* "View.MemoryView":349
* self.flags = flags
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<<
* if <PyObject *> self.view.obj == NULL:
* (<__pyx_buffer *> &self.view).obj = Py_None
*/
__pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 349, __pyx_L1_error)
/* "View.MemoryView":350
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL: # <<<<<<<<<<<<<<
* (<__pyx_buffer *> &self.view).obj = Py_None
* Py_INCREF(Py_None)
*/
__pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":351
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL:
* (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<<
* Py_INCREF(Py_None)
*
*/
((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
/* "View.MemoryView":352
* if <PyObject *> self.view.obj == NULL:
* (<__pyx_buffer *> &self.view).obj = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* global __pyx_memoryview_thread_locks_used
*/
Py_INCREF(Py_None);
/* "View.MemoryView":350
* if type(self) is memoryview or obj is not None:
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL: # <<<<<<<<<<<<<<
* (<__pyx_buffer *> &self.view).obj = Py_None
* Py_INCREF(Py_None)
*/
}
/* "View.MemoryView":348
* self.obj = obj
* self.flags = flags
* if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<<
* __Pyx_GetBuffer(obj, &self.view, flags)
* if <PyObject *> self.view.obj == NULL:
*/
}
/* "View.MemoryView":355
*
* global __pyx_memoryview_thread_locks_used
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<<
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
*/
__pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":356
* global __pyx_memoryview_thread_locks_used
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL:
*/
__pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
/* "View.MemoryView":357
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<<
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock()
*/
__pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
/* "View.MemoryView":355
*
* global __pyx_memoryview_thread_locks_used
* if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<<
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
*/
}
/* "View.MemoryView":358
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL: # <<<<<<<<<<<<<<
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL:
*/
__pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":359
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<<
* if self.lock is NULL:
* raise MemoryError
*/
__pyx_v_self->lock = PyThread_allocate_lock();
/* "View.MemoryView":360
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL: # <<<<<<<<<<<<<<
* raise MemoryError
*
*/
__pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":361
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL:
* raise MemoryError # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
PyErr_NoMemory(); __PYX_ERR(1, 361, __pyx_L1_error)
/* "View.MemoryView":360
* if self.lock is NULL:
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL: # <<<<<<<<<<<<<<
* raise MemoryError
*
*/
}
/* "View.MemoryView":358
* self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
* __pyx_memoryview_thread_locks_used += 1
* if self.lock is NULL: # <<<<<<<<<<<<<<
* self.lock = PyThread_allocate_lock()
* if self.lock is NULL:
*/
}
/* "View.MemoryView":363
* raise MemoryError
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":364
*
* if flags & PyBUF_FORMAT:
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<<
* else:
* self.dtype_is_object = dtype_is_object
*/
__pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L11_bool_binop_done;
}
__pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L11_bool_binop_done:;
__pyx_v_self->dtype_is_object = __pyx_t_1;
/* "View.MemoryView":363
* raise MemoryError
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
* else:
*/
goto __pyx_L10;
}
/* "View.MemoryView":366
* self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
* else:
* self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<<
*
* self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
*/
/*else*/ {
__pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
}
__pyx_L10:;
/* "View.MemoryView":368
* self.dtype_is_object = dtype_is_object
*
* self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<<
* <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
* self.typeinfo = NULL
*/
__pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
/* "View.MemoryView":370
* self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
* <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
* self.typeinfo = NULL # <<<<<<<<<<<<<<
*
* def __dealloc__(memoryview self):
*/
__pyx_v_self->typeinfo = NULL;
/* "View.MemoryView":345
* cdef __Pyx_TypeInfo *typeinfo
*
* def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<<
* self.obj = obj
* self.flags = flags
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":372
* self.typeinfo = NULL
*
* def __dealloc__(memoryview self): # <<<<<<<<<<<<<<
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view)
*/
/* Python wrapper */
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
}
static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
int __pyx_v_i;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
PyThread_type_lock __pyx_t_6;
PyThread_type_lock __pyx_t_7;
__Pyx_RefNannySetupContext("__dealloc__", 0);
/* "View.MemoryView":373
*
* def __dealloc__(memoryview self):
* if self.obj is not None: # <<<<<<<<<<<<<<
* __Pyx_ReleaseBuffer(&self.view)
* elif (<__pyx_buffer *> &self.view).obj == Py_None:
*/
__pyx_t_1 = (__pyx_v_self->obj != Py_None);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":374
* def __dealloc__(memoryview self):
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<<
* elif (<__pyx_buffer *> &self.view).obj == Py_None:
*
*/
__Pyx_ReleaseBuffer((&__pyx_v_self->view));
/* "View.MemoryView":373
*
* def __dealloc__(memoryview self):
* if self.obj is not None: # <<<<<<<<<<<<<<
* __Pyx_ReleaseBuffer(&self.view)
* elif (<__pyx_buffer *> &self.view).obj == Py_None:
*/
goto __pyx_L3;
}
/* "View.MemoryView":375
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view)
* elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<<
*
* (<__pyx_buffer *> &self.view).obj = NULL
*/
__pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":377
* elif (<__pyx_buffer *> &self.view).obj == Py_None:
*
* (<__pyx_buffer *> &self.view).obj = NULL # <<<<<<<<<<<<<<
* Py_DECREF(Py_None)
*
*/
((Py_buffer *)(&__pyx_v_self->view))->obj = NULL;
/* "View.MemoryView":378
*
* (<__pyx_buffer *> &self.view).obj = NULL
* Py_DECREF(Py_None) # <<<<<<<<<<<<<<
*
* cdef int i
*/
Py_DECREF(Py_None);
/* "View.MemoryView":375
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view)
* elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<<
*
* (<__pyx_buffer *> &self.view).obj = NULL
*/
}
__pyx_L3:;
/* "View.MemoryView":382
* cdef int i
* global __pyx_memoryview_thread_locks_used
* if self.lock != NULL: # <<<<<<<<<<<<<<
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock:
*/
__pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":383
* global __pyx_memoryview_thread_locks_used
* if self.lock != NULL:
* for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<<
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1
*/
__pyx_t_3 = __pyx_memoryview_thread_locks_used;
__pyx_t_4 = __pyx_t_3;
for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
__pyx_v_i = __pyx_t_5;
/* "View.MemoryView":384
* if self.lock != NULL:
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used:
*/
__pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":385
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<<
* if i != __pyx_memoryview_thread_locks_used:
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
*/
__pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
/* "View.MemoryView":386
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
*/
__pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":388
* if i != __pyx_memoryview_thread_locks_used:
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<<
* break
* else:
*/
__pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
__pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
/* "View.MemoryView":387
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used:
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
* break
*/
(__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
(__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
/* "View.MemoryView":386
* if __pyx_memoryview_thread_locks[i] is self.lock:
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
*/
}
/* "View.MemoryView":389
* __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
* __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
* break # <<<<<<<<<<<<<<
* else:
* PyThread_free_lock(self.lock)
*/
goto __pyx_L6_break;
/* "View.MemoryView":384
* if self.lock != NULL:
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<<
* __pyx_memoryview_thread_locks_used -= 1
* if i != __pyx_memoryview_thread_locks_used:
*/
}
}
/*else*/ {
/* "View.MemoryView":391
* break
* else:
* PyThread_free_lock(self.lock) # <<<<<<<<<<<<<<
*
* cdef char *get_item_pointer(memoryview self, object index) except NULL:
*/
PyThread_free_lock(__pyx_v_self->lock);
}
__pyx_L6_break:;
/* "View.MemoryView":382
* cdef int i
* global __pyx_memoryview_thread_locks_used
* if self.lock != NULL: # <<<<<<<<<<<<<<
* for i in range(__pyx_memoryview_thread_locks_used):
* if __pyx_memoryview_thread_locks[i] is self.lock:
*/
}
/* "View.MemoryView":372
* self.typeinfo = NULL
*
* def __dealloc__(memoryview self): # <<<<<<<<<<<<<<
* if self.obj is not None:
* __Pyx_ReleaseBuffer(&self.view)
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":393
* PyThread_free_lock(self.lock)
*
* cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<<
* cdef Py_ssize_t dim
* cdef char *itemp = <char *> self.view.buf
*/
static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
Py_ssize_t __pyx_v_dim;
char *__pyx_v_itemp;
PyObject *__pyx_v_idx = NULL;
char *__pyx_r;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
Py_ssize_t __pyx_t_3;
PyObject *(*__pyx_t_4)(PyObject *);
PyObject *__pyx_t_5 = NULL;
Py_ssize_t __pyx_t_6;
char *__pyx_t_7;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("get_item_pointer", 0);
/* "View.MemoryView":395
* cdef char *get_item_pointer(memoryview self, object index) except NULL:
* cdef Py_ssize_t dim
* cdef char *itemp = <char *> self.view.buf # <<<<<<<<<<<<<<
*
* for dim, idx in enumerate(index):
*/
__pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
/* "View.MemoryView":397
* cdef char *itemp = <char *> self.view.buf
*
* for dim, idx in enumerate(index): # <<<<<<<<<<<<<<
* itemp = pybuffer_index(&self.view, itemp, idx, dim)
*
*/
__pyx_t_1 = 0;
if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
__pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
__pyx_t_4 = NULL;
} else {
__pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 397, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 397, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_4)) {
if (likely(PyList_CheckExact(__pyx_t_2))) {
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error)
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
#endif
} else {
if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error)
#else
__pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
#endif
}
} else {
__pyx_t_5 = __pyx_t_4(__pyx_t_2);
if (unlikely(!__pyx_t_5)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(1, 397, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_5);
}
__Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
__pyx_t_5 = 0;
__pyx_v_dim = __pyx_t_1;
__pyx_t_1 = (__pyx_t_1 + 1);
/* "View.MemoryView":398
*
* for dim, idx in enumerate(index):
* itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<<
*
* return itemp
*/
__pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 398, __pyx_L1_error)
__pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(1, 398, __pyx_L1_error)
__pyx_v_itemp = __pyx_t_7;
/* "View.MemoryView":397
* cdef char *itemp = <char *> self.view.buf
*
* for dim, idx in enumerate(index): # <<<<<<<<<<<<<<
* itemp = pybuffer_index(&self.view, itemp, idx, dim)
*
*/
}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":400
* itemp = pybuffer_index(&self.view, itemp, idx, dim)
*
* return itemp # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_itemp;
goto __pyx_L0;
/* "View.MemoryView":393
* PyThread_free_lock(self.lock)
*
* cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<<
* cdef Py_ssize_t dim
* cdef char *itemp = <char *> self.view.buf
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_idx);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":403
*
*
* def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<<
* if index is Ellipsis:
* return self
*/
/* Python wrapper */
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
PyObject *__pyx_v_have_slices = NULL;
PyObject *__pyx_v_indices = NULL;
char *__pyx_v_itemp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
char *__pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__getitem__", 0);
/* "View.MemoryView":404
*
* def __getitem__(memoryview self, object index):
* if index is Ellipsis: # <<<<<<<<<<<<<<
* return self
*
*/
__pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":405
* def __getitem__(memoryview self, object index):
* if index is Ellipsis:
* return self # <<<<<<<<<<<<<<
*
* have_slices, indices = _unellipsify(index, self.view.ndim)
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__pyx_r = ((PyObject *)__pyx_v_self);
goto __pyx_L0;
/* "View.MemoryView":404
*
* def __getitem__(memoryview self, object index):
* if index is Ellipsis: # <<<<<<<<<<<<<<
* return self
*
*/
}
/* "View.MemoryView":407
* return self
*
* have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<<
*
* cdef char *itemp
*/
__pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 407, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (likely(__pyx_t_3 != Py_None)) {
PyObject* sequence = __pyx_t_3;
Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
__PYX_ERR(1, 407, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
#else
__pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 407, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 407, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
#endif
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
} else {
__Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 407, __pyx_L1_error)
}
__pyx_v_have_slices = __pyx_t_4;
__pyx_t_4 = 0;
__pyx_v_indices = __pyx_t_5;
__pyx_t_5 = 0;
/* "View.MemoryView":410
*
* cdef char *itemp
* if have_slices: # <<<<<<<<<<<<<<
* return memview_slice(self, indices)
* else:
*/
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 410, __pyx_L1_error)
if (__pyx_t_2) {
/* "View.MemoryView":411
* cdef char *itemp
* if have_slices:
* return memview_slice(self, indices) # <<<<<<<<<<<<<<
* else:
* itemp = self.get_item_pointer(indices)
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 411, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":410
*
* cdef char *itemp
* if have_slices: # <<<<<<<<<<<<<<
* return memview_slice(self, indices)
* else:
*/
}
/* "View.MemoryView":413
* return memview_slice(self, indices)
* else:
* itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<<
* return self.convert_item_to_object(itemp)
*
*/
/*else*/ {
__pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == ((char *)NULL))) __PYX_ERR(1, 413, __pyx_L1_error)
__pyx_v_itemp = __pyx_t_6;
/* "View.MemoryView":414
* else:
* itemp = self.get_item_pointer(indices)
* return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<<
*
* def __setitem__(memoryview self, object index, object value):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 414, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":403
*
*
* def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<<
* if index is Ellipsis:
* return self
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_have_slices);
__Pyx_XDECREF(__pyx_v_indices);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":416
* return self.convert_item_to_object(itemp)
*
* def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview")
*/
/* Python wrapper */
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
PyObject *__pyx_v_have_slices = NULL;
PyObject *__pyx_v_obj = NULL;
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setitem__", 0);
__Pyx_INCREF(__pyx_v_index);
/* "View.MemoryView":417
*
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly: # <<<<<<<<<<<<<<
* raise TypeError("Cannot assign to read-only memoryview")
*
*/
__pyx_t_1 = (__pyx_v_self->view.readonly != 0);
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":418
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<<
*
* have_slices, index = _unellipsify(index, self.view.ndim)
*/
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 418, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__PYX_ERR(1, 418, __pyx_L1_error)
/* "View.MemoryView":417
*
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly: # <<<<<<<<<<<<<<
* raise TypeError("Cannot assign to read-only memoryview")
*
*/
}
/* "View.MemoryView":420
* raise TypeError("Cannot assign to read-only memoryview")
*
* have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<<
*
* if have_slices:
*/
__pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 420, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (likely(__pyx_t_2 != Py_None)) {
PyObject* sequence = __pyx_t_2;
Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
__PYX_ERR(1, 420, __pyx_L1_error)
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(__pyx_t_4);
#else
__pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 420, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 420, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
} else {
__Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 420, __pyx_L1_error)
}
__pyx_v_have_slices = __pyx_t_3;
__pyx_t_3 = 0;
__Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
__pyx_t_4 = 0;
/* "View.MemoryView":422
* have_slices, index = _unellipsify(index, self.view.ndim)
*
* if have_slices: # <<<<<<<<<<<<<<
* obj = self.is_slice(value)
* if obj:
*/
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 422, __pyx_L1_error)
if (__pyx_t_1) {
/* "View.MemoryView":423
*
* if have_slices:
* obj = self.is_slice(value) # <<<<<<<<<<<<<<
* if obj:
* self.setitem_slice_assignment(self[index], obj)
*/
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 423, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_v_obj = __pyx_t_2;
__pyx_t_2 = 0;
/* "View.MemoryView":424
* if have_slices:
* obj = self.is_slice(value)
* if obj: # <<<<<<<<<<<<<<
* self.setitem_slice_assignment(self[index], obj)
* else:
*/
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 424, __pyx_L1_error)
if (__pyx_t_1) {
/* "View.MemoryView":425
* obj = self.is_slice(value)
* if obj:
* self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<<
* else:
* self.setitem_slice_assign_scalar(self[index], value)
*/
__pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 425, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 425, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
/* "View.MemoryView":424
* if have_slices:
* obj = self.is_slice(value)
* if obj: # <<<<<<<<<<<<<<
* self.setitem_slice_assignment(self[index], obj)
* else:
*/
goto __pyx_L5;
}
/* "View.MemoryView":427
* self.setitem_slice_assignment(self[index], obj)
* else:
* self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<<
* else:
* self.setitem_indexed(index, value)
*/
/*else*/ {
__pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(1, 427, __pyx_L1_error)
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_4), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 427, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_L5:;
/* "View.MemoryView":422
* have_slices, index = _unellipsify(index, self.view.ndim)
*
* if have_slices: # <<<<<<<<<<<<<<
* obj = self.is_slice(value)
* if obj:
*/
goto __pyx_L4;
}
/* "View.MemoryView":429
* self.setitem_slice_assign_scalar(self[index], value)
* else:
* self.setitem_indexed(index, value) # <<<<<<<<<<<<<<
*
* cdef is_slice(self, obj):
*/
/*else*/ {
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 429, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_L4:;
/* "View.MemoryView":416
* return self.convert_item_to_object(itemp)
*
* def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview")
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_have_slices);
__Pyx_XDECREF(__pyx_v_obj);
__Pyx_XDECREF(__pyx_v_index);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":431
* self.setitem_indexed(index, value)
*
* cdef is_slice(self, obj): # <<<<<<<<<<<<<<
* if not isinstance(obj, memoryview):
* try:
*/
static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("is_slice", 0);
__Pyx_INCREF(__pyx_v_obj);
/* "View.MemoryView":432
*
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
*/
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
__pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":433
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
*/
{
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
__Pyx_XGOTREF(__pyx_t_3);
__Pyx_XGOTREF(__pyx_t_4);
__Pyx_XGOTREF(__pyx_t_5);
/*try:*/ {
/* "View.MemoryView":434
* if not isinstance(obj, memoryview):
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
* self.dtype_is_object)
* except TypeError:
*/
__pyx_t_6 = __Pyx_PyInt_From_int(((__pyx_v_self->flags & (~PyBUF_WRITABLE)) | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 434, __pyx_L4_error)
__Pyx_GOTREF(__pyx_t_6);
/* "View.MemoryView":435
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object) # <<<<<<<<<<<<<<
* except TypeError:
* return None
*/
__pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 435, __pyx_L4_error)
__Pyx_GOTREF(__pyx_t_7);
/* "View.MemoryView":434
* if not isinstance(obj, memoryview):
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
* self.dtype_is_object)
* except TypeError:
*/
__pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 434, __pyx_L4_error)
__Pyx_GOTREF(__pyx_t_8);
__Pyx_INCREF(__pyx_v_obj);
__Pyx_GIVEREF(__pyx_v_obj);
PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
__pyx_t_6 = 0;
__pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 434, __pyx_L4_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
__pyx_t_7 = 0;
/* "View.MemoryView":433
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
*/
}
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
goto __pyx_L9_try_end;
__pyx_L4_error:;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
/* "View.MemoryView":436
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
* except TypeError: # <<<<<<<<<<<<<<
* return None
*
*/
__pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
if (__pyx_t_9) {
__Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(1, 436, __pyx_L6_except_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GOTREF(__pyx_t_6);
/* "View.MemoryView":437
* self.dtype_is_object)
* except TypeError:
* return None # <<<<<<<<<<<<<<
*
* return obj
*/
__Pyx_XDECREF(__pyx_r);
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
goto __pyx_L7_except_return;
}
goto __pyx_L6_except_error;
__pyx_L6_except_error:;
/* "View.MemoryView":433
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview):
* try: # <<<<<<<<<<<<<<
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
* self.dtype_is_object)
*/
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
goto __pyx_L1_error;
__pyx_L7_except_return:;
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_XGIVEREF(__pyx_t_5);
__Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
goto __pyx_L0;
__pyx_L9_try_end:;
}
/* "View.MemoryView":432
*
* cdef is_slice(self, obj):
* if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
* try:
* obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
*/
}
/* "View.MemoryView":439
* return None
*
* return obj # <<<<<<<<<<<<<<
*
* cdef setitem_slice_assignment(self, dst, src):
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_obj);
__pyx_r = __pyx_v_obj;
goto __pyx_L0;
/* "View.MemoryView":431
* self.setitem_indexed(index, value)
*
* cdef is_slice(self, obj): # <<<<<<<<<<<<<<
* if not isinstance(obj, memoryview):
* try:
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_obj);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":441
* return obj
*
* cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice dst_slice
* cdef __Pyx_memviewslice src_slice
*/
static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
__Pyx_memviewslice __pyx_v_dst_slice;
__Pyx_memviewslice __pyx_v_src_slice;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice *__pyx_t_1;
__Pyx_memviewslice *__pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
int __pyx_t_5;
int __pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
/* "View.MemoryView":445
* cdef __Pyx_memviewslice src_slice
*
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<<
* get_slice_from_memview(dst, &dst_slice)[0],
* src.ndim, dst.ndim, self.dtype_is_object)
*/
if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(1, 445, __pyx_L1_error)
__pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 445, __pyx_L1_error)
/* "View.MemoryView":446
*
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
* get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<<
* src.ndim, dst.ndim, self.dtype_is_object)
*
*/
if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(1, 446, __pyx_L1_error)
__pyx_t_2 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice)); if (unlikely(__pyx_t_2 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 446, __pyx_L1_error)
/* "View.MemoryView":447
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
* get_slice_from_memview(dst, &dst_slice)[0],
* src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<<
*
* cdef setitem_slice_assign_scalar(self, memoryview dst, value):
*/
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":445
* cdef __Pyx_memviewslice src_slice
*
* memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<<
* get_slice_from_memview(dst, &dst_slice)[0],
* src.ndim, dst.ndim, self.dtype_is_object)
*/
__pyx_t_6 = __pyx_memoryview_copy_contents((__pyx_t_1[0]), (__pyx_t_2[0]), __pyx_t_4, __pyx_t_5, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 445, __pyx_L1_error)
/* "View.MemoryView":441
* return obj
*
* cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice dst_slice
* cdef __Pyx_memviewslice src_slice
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":449
* src.ndim, dst.ndim, self.dtype_is_object)
*
* cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<<
* cdef int array[128]
* cdef void *tmp = NULL
*/
static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) {
int __pyx_v_array[0x80];
void *__pyx_v_tmp;
void *__pyx_v_item;
__Pyx_memviewslice *__pyx_v_dst_slice;
__Pyx_memviewslice __pyx_v_tmp_slice;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice *__pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_t_4;
int __pyx_t_5;
char const *__pyx_t_6;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
PyObject *__pyx_t_9 = NULL;
PyObject *__pyx_t_10 = NULL;
PyObject *__pyx_t_11 = NULL;
PyObject *__pyx_t_12 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
/* "View.MemoryView":451
* cdef setitem_slice_assign_scalar(self, memoryview dst, value):
* cdef int array[128]
* cdef void *tmp = NULL # <<<<<<<<<<<<<<
* cdef void *item
*
*/
__pyx_v_tmp = NULL;
/* "View.MemoryView":456
* cdef __Pyx_memviewslice *dst_slice
* cdef __Pyx_memviewslice tmp_slice
* dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<<
*
* if <size_t>self.view.itemsize > sizeof(array):
*/
__pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 456, __pyx_L1_error)
__pyx_v_dst_slice = __pyx_t_1;
/* "View.MemoryView":458
* dst_slice = get_slice_from_memview(dst, &tmp_slice)
*
* if <size_t>self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<<
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL:
*/
__pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":459
*
* if <size_t>self.view.itemsize > sizeof(array):
* tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<<
* if tmp == NULL:
* raise MemoryError
*/
__pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
/* "View.MemoryView":460
* if <size_t>self.view.itemsize > sizeof(array):
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL: # <<<<<<<<<<<<<<
* raise MemoryError
* item = tmp
*/
__pyx_t_2 = ((__pyx_v_tmp == NULL) != 0);
if (unlikely(__pyx_t_2)) {
/* "View.MemoryView":461
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL:
* raise MemoryError # <<<<<<<<<<<<<<
* item = tmp
* else:
*/
PyErr_NoMemory(); __PYX_ERR(1, 461, __pyx_L1_error)
/* "View.MemoryView":460
* if <size_t>self.view.itemsize > sizeof(array):
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL: # <<<<<<<<<<<<<<
* raise MemoryError
* item = tmp
*/
}
/* "View.MemoryView":462
* if tmp == NULL:
* raise MemoryError
* item = tmp # <<<<<<<<<<<<<<
* else:
* item = <void *> array
*/
__pyx_v_item = __pyx_v_tmp;
/* "View.MemoryView":458
* dst_slice = get_slice_from_memview(dst, &tmp_slice)
*
* if <size_t>self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<<
* tmp = PyMem_Malloc(self.view.itemsize)
* if tmp == NULL:
*/
goto __pyx_L3;
}
/* "View.MemoryView":464
* item = tmp
* else:
* item = <void *> array # <<<<<<<<<<<<<<
*
* try:
*/
/*else*/ {
__pyx_v_item = ((void *)__pyx_v_array);
}
__pyx_L3:;
/* "View.MemoryView":466
* item = <void *> array
*
* try: # <<<<<<<<<<<<<<
* if self.dtype_is_object:
* (<PyObject **> item)[0] = <PyObject *> value
*/
/*try:*/ {
/* "View.MemoryView":467
*
* try:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* (<PyObject **> item)[0] = <PyObject *> value
* else:
*/
__pyx_t_2 = (__pyx_v_self->dtype_is_object != 0);
if (__pyx_t_2) {
/* "View.MemoryView":468
* try:
* if self.dtype_is_object:
* (<PyObject **> item)[0] = <PyObject *> value # <<<<<<<<<<<<<<
* else:
* self.assign_item_from_object(<char *> item, value)
*/
(((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
/* "View.MemoryView":467
*
* try:
* if self.dtype_is_object: # <<<<<<<<<<<<<<
* (<PyObject **> item)[0] = <PyObject *> value
* else:
*/
goto __pyx_L8;
}
/* "View.MemoryView":470
* (<PyObject **> item)[0] = <PyObject *> value
* else:
* self.assign_item_from_object(<char *> item, value) # <<<<<<<<<<<<<<
*
*
*/
/*else*/ {
__pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 470, __pyx_L6_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_L8:;
/* "View.MemoryView":474
*
*
* if self.view.suboffsets != NULL: # <<<<<<<<<<<<<<
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
*/
__pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":475
*
* if self.view.suboffsets != NULL:
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<<
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
* item, self.dtype_is_object)
*/
__pyx_t_3 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 475, __pyx_L6_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":474
*
*
* if self.view.suboffsets != NULL: # <<<<<<<<<<<<<<
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
*/
}
/* "View.MemoryView":476
* if self.view.suboffsets != NULL:
* assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
* slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<<
* item, self.dtype_is_object)
* finally:
*/
__pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object);
}
/* "View.MemoryView":479
* item, self.dtype_is_object)
* finally:
* PyMem_Free(tmp) # <<<<<<<<<<<<<<
*
* cdef setitem_indexed(self, index, value):
*/
/*finally:*/ {
/*normal exit:*/{
PyMem_Free(__pyx_v_tmp);
goto __pyx_L7;
}
__pyx_L6_error:;
/*exception exit:*/{
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
__Pyx_XGOTREF(__pyx_t_7);
__Pyx_XGOTREF(__pyx_t_8);
__Pyx_XGOTREF(__pyx_t_9);
__Pyx_XGOTREF(__pyx_t_10);
__Pyx_XGOTREF(__pyx_t_11);
__Pyx_XGOTREF(__pyx_t_12);
__pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
{
PyMem_Free(__pyx_v_tmp);
}
if (PY_MAJOR_VERSION >= 3) {
__Pyx_XGIVEREF(__pyx_t_10);
__Pyx_XGIVEREF(__pyx_t_11);
__Pyx_XGIVEREF(__pyx_t_12);
__Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
}
__Pyx_XGIVEREF(__pyx_t_7);
__Pyx_XGIVEREF(__pyx_t_8);
__Pyx_XGIVEREF(__pyx_t_9);
__Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
__pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
__pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
goto __pyx_L1_error;
}
__pyx_L7:;
}
/* "View.MemoryView":449
* src.ndim, dst.ndim, self.dtype_is_object)
*
* cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<<
* cdef int array[128]
* cdef void *tmp = NULL
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":481
* PyMem_Free(tmp)
*
* cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<<
* cdef char *itemp = self.get_item_pointer(index)
* self.assign_item_from_object(itemp, value)
*/
static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
char *__pyx_v_itemp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
char *__pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("setitem_indexed", 0);
/* "View.MemoryView":482
*
* cdef setitem_indexed(self, index, value):
* cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<<
* self.assign_item_from_object(itemp, value)
*
*/
__pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == ((char *)NULL))) __PYX_ERR(1, 482, __pyx_L1_error)
__pyx_v_itemp = __pyx_t_1;
/* "View.MemoryView":483
* cdef setitem_indexed(self, index, value):
* cdef char *itemp = self.get_item_pointer(index)
* self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<<
*
* cdef convert_item_to_object(self, char *itemp):
*/
__pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 483, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":481
* PyMem_Free(tmp)
*
* cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<<
* cdef char *itemp = self.get_item_pointer(index)
* self.assign_item_from_object(itemp, value)
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":485
* self.assign_item_from_object(itemp, value)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
PyObject *__pyx_v_struct = NULL;
PyObject *__pyx_v_bytesitem = 0;
PyObject *__pyx_v_result = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
int __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
size_t __pyx_t_10;
int __pyx_t_11;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("convert_item_to_object", 0);
/* "View.MemoryView":488
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
* import struct # <<<<<<<<<<<<<<
* cdef bytes bytesitem
*
*/
__pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 488, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_struct = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":491
* cdef bytes bytesitem
*
* bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<<
* try:
* result = struct.unpack(self.view.format, bytesitem)
*/
__pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 491, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":492
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
{
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
__Pyx_XGOTREF(__pyx_t_2);
__Pyx_XGOTREF(__pyx_t_3);
__Pyx_XGOTREF(__pyx_t_4);
/*try:*/ {
/* "View.MemoryView":493
* bytesitem = itemp[:self.view.itemsize]
* try:
* result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<<
* except struct.error:
* raise ValueError("Unable to convert item to object")
*/
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 493, __pyx_L3_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 493, __pyx_L3_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_7 = NULL;
__pyx_t_8 = 0;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
__pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
if (likely(__pyx_t_7)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
__Pyx_INCREF(__pyx_t_7);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_5, function);
__pyx_t_8 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(__pyx_t_5)) {
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
__pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error)
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
__pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error)
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else
#endif
{
__pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 493, __pyx_L3_error)
__Pyx_GOTREF(__pyx_t_9);
if (__pyx_t_7) {
__Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
}
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
__Pyx_INCREF(__pyx_v_bytesitem);
__Pyx_GIVEREF(__pyx_v_bytesitem);
PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
__pyx_t_6 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_result = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":492
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
}
/* "View.MemoryView":497
* raise ValueError("Unable to convert item to object")
* else:
* if len(self.view.format) == 1: # <<<<<<<<<<<<<<
* return result[0]
* return result
*/
/*else:*/ {
__pyx_t_10 = strlen(__pyx_v_self->view.format);
__pyx_t_11 = ((__pyx_t_10 == 1) != 0);
if (__pyx_t_11) {
/* "View.MemoryView":498
* else:
* if len(self.view.format) == 1:
* return result[0] # <<<<<<<<<<<<<<
* return result
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 498, __pyx_L5_except_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L6_except_return;
/* "View.MemoryView":497
* raise ValueError("Unable to convert item to object")
* else:
* if len(self.view.format) == 1: # <<<<<<<<<<<<<<
* return result[0]
* return result
*/
}
/* "View.MemoryView":499
* if len(self.view.format) == 1:
* return result[0]
* return result # <<<<<<<<<<<<<<
*
* cdef assign_item_from_object(self, char *itemp, object value):
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_result);
__pyx_r = __pyx_v_result;
goto __pyx_L6_except_return;
}
__pyx_L3_error:;
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
/* "View.MemoryView":494
* try:
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error: # <<<<<<<<<<<<<<
* raise ValueError("Unable to convert item to object")
* else:
*/
__Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 494, __pyx_L5_except_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
__pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
if (__pyx_t_8) {
__Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(1, 494, __pyx_L5_except_error)
__Pyx_GOTREF(__pyx_t_9);
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GOTREF(__pyx_t_1);
/* "View.MemoryView":495
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
* raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<<
* else:
* if len(self.view.format) == 1:
*/
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 495, __pyx_L5_except_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__PYX_ERR(1, 495, __pyx_L5_except_error)
}
goto __pyx_L5_except_error;
__pyx_L5_except_error:;
/* "View.MemoryView":492
*
* bytesitem = itemp[:self.view.itemsize]
* try: # <<<<<<<<<<<<<<
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
*/
__Pyx_XGIVEREF(__pyx_t_2);
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
goto __pyx_L1_error;
__pyx_L6_except_return:;
__Pyx_XGIVEREF(__pyx_t_2);
__Pyx_XGIVEREF(__pyx_t_3);
__Pyx_XGIVEREF(__pyx_t_4);
__Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
goto __pyx_L0;
}
/* "View.MemoryView":485
* self.assign_item_from_object(itemp, value)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_struct);
__Pyx_XDECREF(__pyx_v_bytesitem);
__Pyx_XDECREF(__pyx_v_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":501
* return result
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
PyObject *__pyx_v_struct = NULL;
char __pyx_v_c;
PyObject *__pyx_v_bytesvalue = 0;
Py_ssize_t __pyx_v_i;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_t_3;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
int __pyx_t_7;
PyObject *__pyx_t_8 = NULL;
Py_ssize_t __pyx_t_9;
PyObject *__pyx_t_10 = NULL;
char *__pyx_t_11;
char *__pyx_t_12;
char *__pyx_t_13;
char *__pyx_t_14;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("assign_item_from_object", 0);
/* "View.MemoryView":504
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
* import struct # <<<<<<<<<<<<<<
* cdef char c
* cdef bytes bytesvalue
*/
__pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 504, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_struct = __pyx_t_1;
__pyx_t_1 = 0;
/* "View.MemoryView":509
* cdef Py_ssize_t i
*
* if isinstance(value, tuple): # <<<<<<<<<<<<<<
* bytesvalue = struct.pack(self.view.format, *value)
* else:
*/
__pyx_t_2 = PyTuple_Check(__pyx_v_value);
__pyx_t_3 = (__pyx_t_2 != 0);
if (__pyx_t_3) {
/* "View.MemoryView":510
*
* if isinstance(value, tuple):
* bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<<
* else:
* bytesvalue = struct.pack(self.view.format, value)
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 510, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 510, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 510, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 510, __pyx_L1_error)
__pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
__pyx_t_4 = 0;
/* "View.MemoryView":509
* cdef Py_ssize_t i
*
* if isinstance(value, tuple): # <<<<<<<<<<<<<<
* bytesvalue = struct.pack(self.view.format, *value)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":512
* bytesvalue = struct.pack(self.view.format, *value)
* else:
* bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<<
*
* for i, c in enumerate(bytesvalue):
*/
/*else*/ {
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 512, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 512, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_5 = NULL;
__pyx_t_7 = 0;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_6, function);
__pyx_t_7 = 1;
}
}
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(__pyx_t_6)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
__pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
__pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error)
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
} else
#endif
{
__pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 512, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
if (__pyx_t_5) {
__Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
}
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
__Pyx_INCREF(__pyx_v_value);
__Pyx_GIVEREF(__pyx_v_value);
PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
__pyx_t_1 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 512, __pyx_L1_error)
__pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
__pyx_t_4 = 0;
}
__pyx_L3:;
/* "View.MemoryView":514
* bytesvalue = struct.pack(self.view.format, value)
*
* for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
* itemp[i] = c
*
*/
__pyx_t_9 = 0;
if (unlikely(__pyx_v_bytesvalue == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
__PYX_ERR(1, 514, __pyx_L1_error)
}
__Pyx_INCREF(__pyx_v_bytesvalue);
__pyx_t_10 = __pyx_v_bytesvalue;
__pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
__pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
__pyx_t_11 = __pyx_t_14;
__pyx_v_c = (__pyx_t_11[0]);
/* "View.MemoryView":515
*
* for i, c in enumerate(bytesvalue):
* itemp[i] = c # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
__pyx_v_i = __pyx_t_9;
/* "View.MemoryView":514
* bytesvalue = struct.pack(self.view.format, value)
*
* for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
* itemp[i] = c
*
*/
__pyx_t_9 = (__pyx_t_9 + 1);
/* "View.MemoryView":515
*
* for i, c in enumerate(bytesvalue):
* itemp[i] = c # <<<<<<<<<<<<<<
*
* @cname('getbuffer')
*/
(__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
}
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
/* "View.MemoryView":501
* return result
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* """Only used if instantiated manually by the user, or if Cython doesn't
* know how to convert the type"""
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_struct);
__Pyx_XDECREF(__pyx_v_bytesvalue);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":518
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*/
/* Python wrapper */
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
Py_ssize_t *__pyx_t_4;
char *__pyx_t_5;
void *__pyx_t_6;
int __pyx_t_7;
Py_ssize_t __pyx_t_8;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
if (__pyx_v_info == NULL) {
PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
return -1;
}
__Pyx_RefNannySetupContext("__getbuffer__", 0);
__pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
__Pyx_GIVEREF(__pyx_v_info->obj);
/* "View.MemoryView":519
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<<
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
*/
__pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_2 = (__pyx_v_self->view.readonly != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L4_bool_binop_done:;
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":520
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<<
*
* if flags & PyBUF_ND:
*/
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 520, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 520, __pyx_L1_error)
/* "View.MemoryView":519
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<<
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
*/
}
/* "View.MemoryView":522
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
* if flags & PyBUF_ND: # <<<<<<<<<<<<<<
* info.shape = self.view.shape
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":523
*
* if flags & PyBUF_ND:
* info.shape = self.view.shape # <<<<<<<<<<<<<<
* else:
* info.shape = NULL
*/
__pyx_t_4 = __pyx_v_self->view.shape;
__pyx_v_info->shape = __pyx_t_4;
/* "View.MemoryView":522
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*
* if flags & PyBUF_ND: # <<<<<<<<<<<<<<
* info.shape = self.view.shape
* else:
*/
goto __pyx_L6;
}
/* "View.MemoryView":525
* info.shape = self.view.shape
* else:
* info.shape = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_STRIDES:
*/
/*else*/ {
__pyx_v_info->shape = NULL;
}
__pyx_L6:;
/* "View.MemoryView":527
* info.shape = NULL
*
* if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
* info.strides = self.view.strides
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":528
*
* if flags & PyBUF_STRIDES:
* info.strides = self.view.strides # <<<<<<<<<<<<<<
* else:
* info.strides = NULL
*/
__pyx_t_4 = __pyx_v_self->view.strides;
__pyx_v_info->strides = __pyx_t_4;
/* "View.MemoryView":527
* info.shape = NULL
*
* if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
* info.strides = self.view.strides
* else:
*/
goto __pyx_L7;
}
/* "View.MemoryView":530
* info.strides = self.view.strides
* else:
* info.strides = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_INDIRECT:
*/
/*else*/ {
__pyx_v_info->strides = NULL;
}
__pyx_L7:;
/* "View.MemoryView":532
* info.strides = NULL
*
* if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<<
* info.suboffsets = self.view.suboffsets
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":533
*
* if flags & PyBUF_INDIRECT:
* info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<<
* else:
* info.suboffsets = NULL
*/
__pyx_t_4 = __pyx_v_self->view.suboffsets;
__pyx_v_info->suboffsets = __pyx_t_4;
/* "View.MemoryView":532
* info.strides = NULL
*
* if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<<
* info.suboffsets = self.view.suboffsets
* else:
*/
goto __pyx_L8;
}
/* "View.MemoryView":535
* info.suboffsets = self.view.suboffsets
* else:
* info.suboffsets = NULL # <<<<<<<<<<<<<<
*
* if flags & PyBUF_FORMAT:
*/
/*else*/ {
__pyx_v_info->suboffsets = NULL;
}
__pyx_L8:;
/* "View.MemoryView":537
* info.suboffsets = NULL
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.view.format
* else:
*/
__pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":538
*
* if flags & PyBUF_FORMAT:
* info.format = self.view.format # <<<<<<<<<<<<<<
* else:
* info.format = NULL
*/
__pyx_t_5 = __pyx_v_self->view.format;
__pyx_v_info->format = __pyx_t_5;
/* "View.MemoryView":537
* info.suboffsets = NULL
*
* if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
* info.format = self.view.format
* else:
*/
goto __pyx_L9;
}
/* "View.MemoryView":540
* info.format = self.view.format
* else:
* info.format = NULL # <<<<<<<<<<<<<<
*
* info.buf = self.view.buf
*/
/*else*/ {
__pyx_v_info->format = NULL;
}
__pyx_L9:;
/* "View.MemoryView":542
* info.format = NULL
*
* info.buf = self.view.buf # <<<<<<<<<<<<<<
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize
*/
__pyx_t_6 = __pyx_v_self->view.buf;
__pyx_v_info->buf = __pyx_t_6;
/* "View.MemoryView":543
*
* info.buf = self.view.buf
* info.ndim = self.view.ndim # <<<<<<<<<<<<<<
* info.itemsize = self.view.itemsize
* info.len = self.view.len
*/
__pyx_t_7 = __pyx_v_self->view.ndim;
__pyx_v_info->ndim = __pyx_t_7;
/* "View.MemoryView":544
* info.buf = self.view.buf
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize # <<<<<<<<<<<<<<
* info.len = self.view.len
* info.readonly = self.view.readonly
*/
__pyx_t_8 = __pyx_v_self->view.itemsize;
__pyx_v_info->itemsize = __pyx_t_8;
/* "View.MemoryView":545
* info.ndim = self.view.ndim
* info.itemsize = self.view.itemsize
* info.len = self.view.len # <<<<<<<<<<<<<<
* info.readonly = self.view.readonly
* info.obj = self
*/
__pyx_t_8 = __pyx_v_self->view.len;
__pyx_v_info->len = __pyx_t_8;
/* "View.MemoryView":546
* info.itemsize = self.view.itemsize
* info.len = self.view.len
* info.readonly = self.view.readonly # <<<<<<<<<<<<<<
* info.obj = self
*
*/
__pyx_t_1 = __pyx_v_self->view.readonly;
__pyx_v_info->readonly = __pyx_t_1;
/* "View.MemoryView":547
* info.len = self.view.len
* info.readonly = self.view.readonly
* info.obj = self # <<<<<<<<<<<<<<
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
*/
__Pyx_INCREF(((PyObject *)__pyx_v_self));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self));
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj);
__pyx_v_info->obj = ((PyObject *)__pyx_v_self);
/* "View.MemoryView":518
*
* @cname('getbuffer')
* def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview")
*/
/* function exit code */
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
if (__pyx_v_info->obj != NULL) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
goto __pyx_L2;
__pyx_L0:;
if (__pyx_v_info->obj == Py_None) {
__Pyx_GOTREF(__pyx_v_info->obj);
__Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
}
__pyx_L2:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":553
*
* @property
* def T(self): # <<<<<<<<<<<<<<
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":554
* @property
* def T(self):
* cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<<
* transpose_memslice(&result.from_slice)
* return result
*/
__pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 554, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(1, 554, __pyx_L1_error)
__pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
__pyx_t_1 = 0;
/* "View.MemoryView":555
* def T(self):
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 555, __pyx_L1_error)
/* "View.MemoryView":556
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
* return result # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = ((PyObject *)__pyx_v_result);
goto __pyx_L0;
/* "View.MemoryView":553
*
* @property
* def T(self): # <<<<<<<<<<<<<<
* cdef _memoryviewslice result = memoryview_copy(self)
* transpose_memslice(&result.from_slice)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":559
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.obj
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":560
* @property
* def base(self):
* return self.obj # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->obj);
__pyx_r = __pyx_v_self->obj;
goto __pyx_L0;
/* "View.MemoryView":559
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.obj
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":563
*
* @property
* def shape(self): # <<<<<<<<<<<<<<
* return tuple([length for length in self.view.shape[:self.view.ndim]])
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_v_length;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
Py_ssize_t *__pyx_t_2;
Py_ssize_t *__pyx_t_3;
Py_ssize_t *__pyx_t_4;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":564
* @property
* def shape(self):
* return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 564, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
__pyx_t_2 = __pyx_t_4;
__pyx_v_length = (__pyx_t_2[0]);
__pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(1, 564, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
}
__pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
/* "View.MemoryView":563
*
* @property
* def shape(self): # <<<<<<<<<<<<<<
* return tuple([length for length in self.view.shape[:self.view.ndim]])
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":567
*
* @property
* def strides(self): # <<<<<<<<<<<<<<
* if self.view.strides == NULL:
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_v_stride;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
Py_ssize_t *__pyx_t_3;
Py_ssize_t *__pyx_t_4;
Py_ssize_t *__pyx_t_5;
PyObject *__pyx_t_6 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":568
* @property
* def strides(self):
* if self.view.strides == NULL: # <<<<<<<<<<<<<<
*
* raise ValueError("Buffer view does not expose strides")
*/
__pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":570
* if self.view.strides == NULL:
*
* raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<<
*
* return tuple([stride for stride in self.view.strides[:self.view.ndim]])
*/
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 570, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__PYX_ERR(1, 570, __pyx_L1_error)
/* "View.MemoryView":568
* @property
* def strides(self):
* if self.view.strides == NULL: # <<<<<<<<<<<<<<
*
* raise ValueError("Buffer view does not expose strides")
*/
}
/* "View.MemoryView":572
* raise ValueError("Buffer view does not expose strides")
*
* return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 572, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
__pyx_t_3 = __pyx_t_5;
__pyx_v_stride = (__pyx_t_3[0]);
__pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 572, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
}
__pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_6;
__pyx_t_6 = 0;
goto __pyx_L0;
/* "View.MemoryView":567
*
* @property
* def strides(self): # <<<<<<<<<<<<<<
* if self.view.strides == NULL:
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":575
*
* @property
* def suboffsets(self): # <<<<<<<<<<<<<<
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_v_suboffset;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
Py_ssize_t *__pyx_t_4;
Py_ssize_t *__pyx_t_5;
Py_ssize_t *__pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":576
* @property
* def suboffsets(self):
* if self.view.suboffsets == NULL: # <<<<<<<<<<<<<<
* return (-1,) * self.view.ndim
*
*/
__pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":577
* def suboffsets(self):
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim # <<<<<<<<<<<<<<
*
* return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_Multiply(__pyx_tuple__16, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":576
* @property
* def suboffsets(self):
* if self.view.suboffsets == NULL: # <<<<<<<<<<<<<<
* return (-1,) * self.view.ndim
*
*/
}
/* "View.MemoryView":579
* return (-1,) * self.view.ndim
*
* return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 579, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
__pyx_t_4 = __pyx_t_6;
__pyx_v_suboffset = (__pyx_t_4[0]);
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(1, 579, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":575
*
* @property
* def suboffsets(self): # <<<<<<<<<<<<<<
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":582
*
* @property
* def ndim(self): # <<<<<<<<<<<<<<
* return self.view.ndim
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":583
* @property
* def ndim(self):
* return self.view.ndim # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 583, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":582
*
* @property
* def ndim(self): # <<<<<<<<<<<<<<
* return self.view.ndim
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":586
*
* @property
* def itemsize(self): # <<<<<<<<<<<<<<
* return self.view.itemsize
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":587
* @property
* def itemsize(self):
* return self.view.itemsize # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":586
*
* @property
* def itemsize(self): # <<<<<<<<<<<<<<
* return self.view.itemsize
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":590
*
* @property
* def nbytes(self): # <<<<<<<<<<<<<<
* return self.size * self.view.itemsize
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":591
* @property
* def nbytes(self):
* return self.size * self.view.itemsize # <<<<<<<<<<<<<<
*
* @property
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 591, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 591, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 591, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":590
*
* @property
* def nbytes(self): # <<<<<<<<<<<<<<
* return self.size * self.view.itemsize
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":594
*
* @property
* def size(self): # <<<<<<<<<<<<<<
* if self._size is None:
* result = 1
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_v_result = NULL;
PyObject *__pyx_v_length = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
Py_ssize_t *__pyx_t_3;
Py_ssize_t *__pyx_t_4;
Py_ssize_t *__pyx_t_5;
PyObject *__pyx_t_6 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":595
* @property
* def size(self):
* if self._size is None: # <<<<<<<<<<<<<<
* result = 1
*
*/
__pyx_t_1 = (__pyx_v_self->_size == Py_None);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":596
* def size(self):
* if self._size is None:
* result = 1 # <<<<<<<<<<<<<<
*
* for length in self.view.shape[:self.view.ndim]:
*/
__Pyx_INCREF(__pyx_int_1);
__pyx_v_result = __pyx_int_1;
/* "View.MemoryView":598
* result = 1
*
* for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<<
* result *= length
*
*/
__pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
__pyx_t_3 = __pyx_t_5;
__pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 598, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
__pyx_t_6 = 0;
/* "View.MemoryView":599
*
* for length in self.view.shape[:self.view.ndim]:
* result *= length # <<<<<<<<<<<<<<
*
* self._size = result
*/
__pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 599, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
__pyx_t_6 = 0;
}
/* "View.MemoryView":601
* result *= length
*
* self._size = result # <<<<<<<<<<<<<<
*
* return self._size
*/
__Pyx_INCREF(__pyx_v_result);
__Pyx_GIVEREF(__pyx_v_result);
__Pyx_GOTREF(__pyx_v_self->_size);
__Pyx_DECREF(__pyx_v_self->_size);
__pyx_v_self->_size = __pyx_v_result;
/* "View.MemoryView":595
* @property
* def size(self):
* if self._size is None: # <<<<<<<<<<<<<<
* result = 1
*
*/
}
/* "View.MemoryView":603
* self._size = result
*
* return self._size # <<<<<<<<<<<<<<
*
* def __len__(self):
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->_size);
__pyx_r = __pyx_v_self->_size;
goto __pyx_L0;
/* "View.MemoryView":594
*
* @property
* def size(self): # <<<<<<<<<<<<<<
* if self._size is None:
* result = 1
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_result);
__Pyx_XDECREF(__pyx_v_length);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":605
* return self._size
*
* def __len__(self): # <<<<<<<<<<<<<<
* if self.view.ndim >= 1:
* return self.view.shape[0]
*/
/* Python wrapper */
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
Py_ssize_t __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
__Pyx_RefNannySetupContext("__len__", 0);
/* "View.MemoryView":606
*
* def __len__(self):
* if self.view.ndim >= 1: # <<<<<<<<<<<<<<
* return self.view.shape[0]
*
*/
__pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":607
* def __len__(self):
* if self.view.ndim >= 1:
* return self.view.shape[0] # <<<<<<<<<<<<<<
*
* return 0
*/
__pyx_r = (__pyx_v_self->view.shape[0]);
goto __pyx_L0;
/* "View.MemoryView":606
*
* def __len__(self):
* if self.view.ndim >= 1: # <<<<<<<<<<<<<<
* return self.view.shape[0]
*
*/
}
/* "View.MemoryView":609
* return self.view.shape[0]
*
* return 0 # <<<<<<<<<<<<<<
*
* def __repr__(self):
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":605
* return self._size
*
* def __len__(self): # <<<<<<<<<<<<<<
* if self.view.ndim >= 1:
* return self.view.shape[0]
*/
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":611
* return 0
*
* def __repr__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
* id(self))
*/
/* Python wrapper */
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__repr__", 0);
/* "View.MemoryView":612
*
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__, # <<<<<<<<<<<<<<
* id(self))
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "View.MemoryView":613
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
* id(self)) # <<<<<<<<<<<<<<
*
* def __str__(self):
*/
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 613, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
/* "View.MemoryView":612
*
* def __repr__(self):
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__, # <<<<<<<<<<<<<<
* id(self))
*
*/
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":611
* return 0
*
* def __repr__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
* id(self))
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":615
* id(self))
*
* def __str__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
*
*/
/* Python wrapper */
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
/* "View.MemoryView":616
*
* def __str__(self):
* return "<MemoryView of %r object>" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":615
* id(self))
*
* def __str__(self): # <<<<<<<<<<<<<<
* return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":619
*
*
* def is_c_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice *__pyx_v_mslice;
__Pyx_memviewslice __pyx_v_tmp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice *__pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("is_c_contig", 0);
/* "View.MemoryView":622
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
* return slice_is_contig(mslice[0], 'C', self.view.ndim)
*
*/
__pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 622, __pyx_L1_error)
__pyx_v_mslice = __pyx_t_1;
/* "View.MemoryView":623
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp)
* return slice_is_contig(mslice[0], 'C', self.view.ndim) # <<<<<<<<<<<<<<
*
* def is_f_contig(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 623, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":619
*
*
* def is_c_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":625
* return slice_is_contig(mslice[0], 'C', self.view.ndim)
*
* def is_f_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice *__pyx_v_mslice;
__Pyx_memviewslice __pyx_v_tmp;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice *__pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("is_f_contig", 0);
/* "View.MemoryView":628
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
* return slice_is_contig(mslice[0], 'F', self.view.ndim)
*
*/
__pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 628, __pyx_L1_error)
__pyx_v_mslice = __pyx_t_1;
/* "View.MemoryView":629
* cdef __Pyx_memviewslice tmp
* mslice = get_slice_from_memview(self, &tmp)
* return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<<
*
* def copy(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 629, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":625
* return slice_is_contig(mslice[0], 'C', self.view.ndim)
*
* def is_f_contig(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice *mslice
* cdef __Pyx_memviewslice tmp
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":631
* return slice_is_contig(mslice[0], 'F', self.view.ndim)
*
* def copy(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice mslice
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice __pyx_v_mslice;
int __pyx_v_flags;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("copy", 0);
/* "View.MemoryView":633
* def copy(self):
* cdef __Pyx_memviewslice mslice
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<<
*
* slice_copy(self, &mslice)
*/
__pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
/* "View.MemoryView":635
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
*
* slice_copy(self, &mslice) # <<<<<<<<<<<<<<
* mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
* self.view.itemsize,
*/
__pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
/* "View.MemoryView":636
*
* slice_copy(self, &mslice)
* mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<<
* self.view.itemsize,
* flags|PyBUF_C_CONTIGUOUS,
*/
__pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 636, __pyx_L1_error)
__pyx_v_mslice = __pyx_t_1;
/* "View.MemoryView":641
* self.dtype_is_object)
*
* return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<<
*
* def copy_fortran(self):
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 641, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":631
* return slice_is_contig(mslice[0], 'F', self.view.ndim)
*
* def copy(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice mslice
* cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":643
* return memoryview_copy_from_slice(self, &mslice)
*
* def copy_fortran(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice src, dst
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
*/
/* Python wrapper */
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
__pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
__Pyx_memviewslice __pyx_v_src;
__Pyx_memviewslice __pyx_v_dst;
int __pyx_v_flags;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_memviewslice __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("copy_fortran", 0);
/* "View.MemoryView":645
* def copy_fortran(self):
* cdef __Pyx_memviewslice src, dst
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<<
*
* slice_copy(self, &src)
*/
__pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
/* "View.MemoryView":647
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
*
* slice_copy(self, &src) # <<<<<<<<<<<<<<
* dst = slice_copy_contig(&src, "fortran", self.view.ndim,
* self.view.itemsize,
*/
__pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
/* "View.MemoryView":648
*
* slice_copy(self, &src)
* dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<<
* self.view.itemsize,
* flags|PyBUF_F_CONTIGUOUS,
*/
__pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 648, __pyx_L1_error)
__pyx_v_dst = __pyx_t_1;
/* "View.MemoryView":653
* self.dtype_is_object)
*
* return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 653, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":643
* return memoryview_copy_from_slice(self, &mslice)
*
* def copy_fortran(self): # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice src, dst
* cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 2, __pyx_L1_error)
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 4, __pyx_L1_error)
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":657
*
* @cname('__pyx_memoryview_new')
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<<
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo
*/
static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
struct __pyx_memoryview_obj *__pyx_v_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
/* "View.MemoryView":658
* @cname('__pyx_memoryview_new')
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
* cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<<
* result.typeinfo = typeinfo
* return result
*/
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 658, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 658, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_o);
__Pyx_GIVEREF(__pyx_v_o);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
__pyx_t_2 = 0;
/* "View.MemoryView":659
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_v_result->typeinfo = __pyx_v_typeinfo;
/* "View.MemoryView":660
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo
* return result # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_check')
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = ((PyObject *)__pyx_v_result);
goto __pyx_L0;
/* "View.MemoryView":657
*
* @cname('__pyx_memoryview_new')
* cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<<
* cdef memoryview result = memoryview(o, flags, dtype_is_object)
* result.typeinfo = typeinfo
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":663
*
* @cname('__pyx_memoryview_check')
* cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<<
* return isinstance(o, memoryview)
*
*/
static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
__Pyx_RefNannySetupContext("memoryview_check", 0);
/* "View.MemoryView":664
* @cname('__pyx_memoryview_check')
* cdef inline bint memoryview_check(object o):
* return isinstance(o, memoryview) # <<<<<<<<<<<<<<
*
* cdef tuple _unellipsify(object index, int ndim):
*/
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
__pyx_r = __pyx_t_1;
goto __pyx_L0;
/* "View.MemoryView":663
*
* @cname('__pyx_memoryview_check')
* cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<<
* return isinstance(o, memoryview)
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":666
* return isinstance(o, memoryview)
*
* cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<<
* """
* Replace all ellipses with full slices and fill incomplete indices with
*/
static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
PyObject *__pyx_v_tup = NULL;
PyObject *__pyx_v_result = NULL;
int __pyx_v_have_slices;
int __pyx_v_seen_ellipsis;
CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
PyObject *__pyx_v_item = NULL;
Py_ssize_t __pyx_v_nslices;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
Py_ssize_t __pyx_t_5;
PyObject *(*__pyx_t_6)(PyObject *);
PyObject *__pyx_t_7 = NULL;
Py_ssize_t __pyx_t_8;
int __pyx_t_9;
int __pyx_t_10;
PyObject *__pyx_t_11 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("_unellipsify", 0);
/* "View.MemoryView":671
* full slices.
* """
* if not isinstance(index, tuple): # <<<<<<<<<<<<<<
* tup = (index,)
* else:
*/
__pyx_t_1 = PyTuple_Check(__pyx_v_index);
__pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":672
* """
* if not isinstance(index, tuple):
* tup = (index,) # <<<<<<<<<<<<<<
* else:
* tup = index
*/
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 672, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_index);
__Pyx_GIVEREF(__pyx_v_index);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
__pyx_v_tup = __pyx_t_3;
__pyx_t_3 = 0;
/* "View.MemoryView":671
* full slices.
* """
* if not isinstance(index, tuple): # <<<<<<<<<<<<<<
* tup = (index,)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":674
* tup = (index,)
* else:
* tup = index # <<<<<<<<<<<<<<
*
* result = []
*/
/*else*/ {
__Pyx_INCREF(__pyx_v_index);
__pyx_v_tup = __pyx_v_index;
}
__pyx_L3:;
/* "View.MemoryView":676
* tup = index
*
* result = [] # <<<<<<<<<<<<<<
* have_slices = False
* seen_ellipsis = False
*/
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 676, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_v_result = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":677
*
* result = []
* have_slices = False # <<<<<<<<<<<<<<
* seen_ellipsis = False
* for idx, item in enumerate(tup):
*/
__pyx_v_have_slices = 0;
/* "View.MemoryView":678
* result = []
* have_slices = False
* seen_ellipsis = False # <<<<<<<<<<<<<<
* for idx, item in enumerate(tup):
* if item is Ellipsis:
*/
__pyx_v_seen_ellipsis = 0;
/* "View.MemoryView":679
* have_slices = False
* seen_ellipsis = False
* for idx, item in enumerate(tup): # <<<<<<<<<<<<<<
* if item is Ellipsis:
* if not seen_ellipsis:
*/
__Pyx_INCREF(__pyx_int_0);
__pyx_t_3 = __pyx_int_0;
if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
__pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
__pyx_t_6 = NULL;
} else {
__pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 679, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 679, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_6)) {
if (likely(PyList_CheckExact(__pyx_t_4))) {
if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error)
#else
__pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
#endif
} else {
if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error)
#else
__pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
#endif
}
} else {
__pyx_t_7 = __pyx_t_6(__pyx_t_4);
if (unlikely(!__pyx_t_7)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(1, 679, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_7);
}
__Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
__pyx_t_7 = 0;
__Pyx_INCREF(__pyx_t_3);
__Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
__pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_3);
__pyx_t_3 = __pyx_t_7;
__pyx_t_7 = 0;
/* "View.MemoryView":680
* seen_ellipsis = False
* for idx, item in enumerate(tup):
* if item is Ellipsis: # <<<<<<<<<<<<<<
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1))
*/
__pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
__pyx_t_1 = (__pyx_t_2 != 0);
if (__pyx_t_1) {
/* "View.MemoryView":681
* for idx, item in enumerate(tup):
* if item is Ellipsis:
* if not seen_ellipsis: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * (ndim - len(tup) + 1))
* seen_ellipsis = True
*/
__pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":682
* if item is Ellipsis:
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<<
* seen_ellipsis = True
* else:
*/
__pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(1, 682, __pyx_L1_error)
__pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 682, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
{ Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
__Pyx_INCREF(__pyx_slice__19);
__Pyx_GIVEREF(__pyx_slice__19);
PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__19);
}
}
__pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 682, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
/* "View.MemoryView":683
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1))
* seen_ellipsis = True # <<<<<<<<<<<<<<
* else:
* result.append(slice(None))
*/
__pyx_v_seen_ellipsis = 1;
/* "View.MemoryView":681
* for idx, item in enumerate(tup):
* if item is Ellipsis:
* if not seen_ellipsis: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * (ndim - len(tup) + 1))
* seen_ellipsis = True
*/
goto __pyx_L7;
}
/* "View.MemoryView":685
* seen_ellipsis = True
* else:
* result.append(slice(None)) # <<<<<<<<<<<<<<
* have_slices = True
* else:
*/
/*else*/ {
__pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__19); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 685, __pyx_L1_error)
}
__pyx_L7:;
/* "View.MemoryView":686
* else:
* result.append(slice(None))
* have_slices = True # <<<<<<<<<<<<<<
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item):
*/
__pyx_v_have_slices = 1;
/* "View.MemoryView":680
* seen_ellipsis = False
* for idx, item in enumerate(tup):
* if item is Ellipsis: # <<<<<<<<<<<<<<
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1))
*/
goto __pyx_L6;
}
/* "View.MemoryView":688
* have_slices = True
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<<
* raise TypeError("Cannot index with type '%s'" % type(item))
*
*/
/*else*/ {
__pyx_t_2 = PySlice_Check(__pyx_v_item);
__pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
if (__pyx_t_10) {
} else {
__pyx_t_1 = __pyx_t_10;
goto __pyx_L9_bool_binop_done;
}
__pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
__pyx_t_1 = __pyx_t_10;
__pyx_L9_bool_binop_done:;
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":689
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item):
* raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<<
*
* have_slices = have_slices or isinstance(item, slice)
*/
__pyx_t_7 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 689, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 689, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_11);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_Raise(__pyx_t_11, 0, 0, 0);
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
__PYX_ERR(1, 689, __pyx_L1_error)
/* "View.MemoryView":688
* have_slices = True
* else:
* if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<<
* raise TypeError("Cannot index with type '%s'" % type(item))
*
*/
}
/* "View.MemoryView":691
* raise TypeError("Cannot index with type '%s'" % type(item))
*
* have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<<
* result.append(item)
*
*/
__pyx_t_10 = (__pyx_v_have_slices != 0);
if (!__pyx_t_10) {
} else {
__pyx_t_1 = __pyx_t_10;
goto __pyx_L11_bool_binop_done;
}
__pyx_t_10 = PySlice_Check(__pyx_v_item);
__pyx_t_2 = (__pyx_t_10 != 0);
__pyx_t_1 = __pyx_t_2;
__pyx_L11_bool_binop_done:;
__pyx_v_have_slices = __pyx_t_1;
/* "View.MemoryView":692
*
* have_slices = have_slices or isinstance(item, slice)
* result.append(item) # <<<<<<<<<<<<<<
*
* nslices = ndim - len(result)
*/
__pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 692, __pyx_L1_error)
}
__pyx_L6:;
/* "View.MemoryView":679
* have_slices = False
* seen_ellipsis = False
* for idx, item in enumerate(tup): # <<<<<<<<<<<<<<
* if item is Ellipsis:
* if not seen_ellipsis:
*/
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":694
* result.append(item)
*
* nslices = ndim - len(result) # <<<<<<<<<<<<<<
* if nslices:
* result.extend([slice(None)] * nslices)
*/
__pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 694, __pyx_L1_error)
__pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
/* "View.MemoryView":695
*
* nslices = ndim - len(result)
* if nslices: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * nslices)
*
*/
__pyx_t_1 = (__pyx_v_nslices != 0);
if (__pyx_t_1) {
/* "View.MemoryView":696
* nslices = ndim - len(result)
* if nslices:
* result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<<
*
* return have_slices or nslices, tuple(result)
*/
__pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 696, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
{ Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
__Pyx_INCREF(__pyx_slice__19);
__Pyx_GIVEREF(__pyx_slice__19);
PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__19);
}
}
__pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 696, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":695
*
* nslices = ndim - len(result)
* if nslices: # <<<<<<<<<<<<<<
* result.extend([slice(None)] * nslices)
*
*/
}
/* "View.MemoryView":698
* result.extend([slice(None)] * nslices)
*
* return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<<
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
*/
__Pyx_XDECREF(__pyx_r);
if (!__pyx_v_have_slices) {
} else {
__pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L14_bool_binop_done;
}
__pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = __pyx_t_4;
__pyx_t_4 = 0;
__pyx_L14_bool_binop_done:;
__pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 698, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_11);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
__pyx_t_3 = 0;
__pyx_t_4 = 0;
__pyx_r = ((PyObject*)__pyx_t_11);
__pyx_t_11 = 0;
goto __pyx_L0;
/* "View.MemoryView":666
* return isinstance(o, memoryview)
*
* cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<<
* """
* Replace all ellipses with full slices and fill incomplete indices with
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_tup);
__Pyx_XDECREF(__pyx_v_result);
__Pyx_XDECREF(__pyx_v_idx);
__Pyx_XDECREF(__pyx_v_item);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":700
* return have_slices or nslices, tuple(result)
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<<
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
*/
static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
Py_ssize_t __pyx_v_suboffset;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
Py_ssize_t *__pyx_t_1;
Py_ssize_t *__pyx_t_2;
Py_ssize_t *__pyx_t_3;
int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
/* "View.MemoryView":701
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
* for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<<
* if suboffset >= 0:
* raise ValueError("Indirect dimensions not supported")
*/
__pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
__pyx_t_1 = __pyx_t_3;
__pyx_v_suboffset = (__pyx_t_1[0]);
/* "View.MemoryView":702
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* raise ValueError("Indirect dimensions not supported")
*
*/
__pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
if (unlikely(__pyx_t_4)) {
/* "View.MemoryView":703
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
* raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 703, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__PYX_ERR(1, 703, __pyx_L1_error)
/* "View.MemoryView":702
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* raise ValueError("Indirect dimensions not supported")
*
*/
}
}
/* "View.MemoryView":700
* return have_slices or nslices, tuple(result)
*
* cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<<
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":710
*
* @cname('__pyx_memview_slice')
* cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<<
* cdef int new_ndim = 0, suboffset_dim = -1, dim
* cdef bint negative_step
*/
static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
int __pyx_v_new_ndim;
int __pyx_v_suboffset_dim;
int __pyx_v_dim;
__Pyx_memviewslice __pyx_v_src;
__Pyx_memviewslice __pyx_v_dst;
__Pyx_memviewslice *__pyx_v_p_src;
struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
__Pyx_memviewslice *__pyx_v_p_dst;
int *__pyx_v_p_suboffset_dim;
Py_ssize_t __pyx_v_start;
Py_ssize_t __pyx_v_stop;
Py_ssize_t __pyx_v_step;
int __pyx_v_have_start;
int __pyx_v_have_stop;
int __pyx_v_have_step;
PyObject *__pyx_v_index = NULL;
struct __pyx_memoryview_obj *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
struct __pyx_memoryview_obj *__pyx_t_4;
char *__pyx_t_5;
int __pyx_t_6;
Py_ssize_t __pyx_t_7;
PyObject *(*__pyx_t_8)(PyObject *);
PyObject *__pyx_t_9 = NULL;
Py_ssize_t __pyx_t_10;
int __pyx_t_11;
Py_ssize_t __pyx_t_12;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memview_slice", 0);
/* "View.MemoryView":711
* @cname('__pyx_memview_slice')
* cdef memoryview memview_slice(memoryview memview, object indices):
* cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<<
* cdef bint negative_step
* cdef __Pyx_memviewslice src, dst
*/
__pyx_v_new_ndim = 0;
__pyx_v_suboffset_dim = -1;
/* "View.MemoryView":718
*
*
* memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<<
*
* cdef _memoryviewslice memviewsliceobj
*/
(void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
/* "View.MemoryView":722
* cdef _memoryviewslice memviewsliceobj
*
* assert memview.view.ndim > 0 # <<<<<<<<<<<<<<
*
* if isinstance(memview, _memoryviewslice):
*/
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 722, __pyx_L1_error)
}
}
#endif
/* "View.MemoryView":724
* assert memview.view.ndim > 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* memviewsliceobj = memview
* p_src = &memviewsliceobj.from_slice
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":725
*
* if isinstance(memview, _memoryviewslice):
* memviewsliceobj = memview # <<<<<<<<<<<<<<
* p_src = &memviewsliceobj.from_slice
* else:
*/
if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 725, __pyx_L1_error)
__pyx_t_3 = ((PyObject *)__pyx_v_memview);
__Pyx_INCREF(__pyx_t_3);
__pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":726
* if isinstance(memview, _memoryviewslice):
* memviewsliceobj = memview
* p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<<
* else:
* slice_copy(memview, &src)
*/
__pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
/* "View.MemoryView":724
* assert memview.view.ndim > 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* memviewsliceobj = memview
* p_src = &memviewsliceobj.from_slice
*/
goto __pyx_L3;
}
/* "View.MemoryView":728
* p_src = &memviewsliceobj.from_slice
* else:
* slice_copy(memview, &src) # <<<<<<<<<<<<<<
* p_src = &src
*
*/
/*else*/ {
__pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
/* "View.MemoryView":729
* else:
* slice_copy(memview, &src)
* p_src = &src # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_p_src = (&__pyx_v_src);
}
__pyx_L3:;
/* "View.MemoryView":735
*
*
* dst.memview = p_src.memview # <<<<<<<<<<<<<<
* dst.data = p_src.data
*
*/
__pyx_t_4 = __pyx_v_p_src->memview;
__pyx_v_dst.memview = __pyx_t_4;
/* "View.MemoryView":736
*
* dst.memview = p_src.memview
* dst.data = p_src.data # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __pyx_v_p_src->data;
__pyx_v_dst.data = __pyx_t_5;
/* "View.MemoryView":741
*
*
* cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<<
* cdef int *p_suboffset_dim = &suboffset_dim
* cdef Py_ssize_t start, stop, step
*/
__pyx_v_p_dst = (&__pyx_v_dst);
/* "View.MemoryView":742
*
* cdef __Pyx_memviewslice *p_dst = &dst
* cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<<
* cdef Py_ssize_t start, stop, step
* cdef bint have_start, have_stop, have_step
*/
__pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
/* "View.MemoryView":746
* cdef bint have_start, have_stop, have_step
*
* for dim, index in enumerate(indices): # <<<<<<<<<<<<<<
* if PyIndex_Check(index):
* slice_memviewslice(
*/
__pyx_t_6 = 0;
if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
__pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
__pyx_t_8 = NULL;
} else {
__pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 746, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 746, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_8)) {
if (likely(PyList_CheckExact(__pyx_t_3))) {
if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error)
#else
__pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
#endif
} else {
if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error)
#else
__pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
#endif
}
} else {
__pyx_t_9 = __pyx_t_8(__pyx_t_3);
if (unlikely(!__pyx_t_9)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(1, 746, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_9);
}
__Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
__pyx_t_9 = 0;
__pyx_v_dim = __pyx_t_6;
__pyx_t_6 = (__pyx_t_6 + 1);
/* "View.MemoryView":747
*
* for dim, index in enumerate(indices):
* if PyIndex_Check(index): # <<<<<<<<<<<<<<
* slice_memviewslice(
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
*/
__pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":751
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
* dim, new_ndim, p_suboffset_dim,
* index, 0, 0, # start, stop, step # <<<<<<<<<<<<<<
* 0, 0, 0, # have_{start,stop,step}
* False)
*/
__pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 751, __pyx_L1_error)
/* "View.MemoryView":748
* for dim, index in enumerate(indices):
* if PyIndex_Check(index):
* slice_memviewslice( # <<<<<<<<<<<<<<
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
* dim, new_ndim, p_suboffset_dim,
*/
__pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 748, __pyx_L1_error)
/* "View.MemoryView":747
*
* for dim, index in enumerate(indices):
* if PyIndex_Check(index): # <<<<<<<<<<<<<<
* slice_memviewslice(
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
*/
goto __pyx_L6;
}
/* "View.MemoryView":754
* 0, 0, 0, # have_{start,stop,step}
* False)
* elif index is None: # <<<<<<<<<<<<<<
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0
*/
__pyx_t_2 = (__pyx_v_index == Py_None);
__pyx_t_1 = (__pyx_t_2 != 0);
if (__pyx_t_1) {
/* "View.MemoryView":755
* False)
* elif index is None:
* p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<<
* p_dst.strides[new_ndim] = 0
* p_dst.suboffsets[new_ndim] = -1
*/
(__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
/* "View.MemoryView":756
* elif index is None:
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<<
* p_dst.suboffsets[new_ndim] = -1
* new_ndim += 1
*/
(__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
/* "View.MemoryView":757
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0
* p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<<
* new_ndim += 1
* else:
*/
(__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
/* "View.MemoryView":758
* p_dst.strides[new_ndim] = 0
* p_dst.suboffsets[new_ndim] = -1
* new_ndim += 1 # <<<<<<<<<<<<<<
* else:
* start = index.start or 0
*/
__pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
/* "View.MemoryView":754
* 0, 0, 0, # have_{start,stop,step}
* False)
* elif index is None: # <<<<<<<<<<<<<<
* p_dst.shape[new_ndim] = 1
* p_dst.strides[new_ndim] = 0
*/
goto __pyx_L6;
}
/* "View.MemoryView":760
* new_ndim += 1
* else:
* start = index.start or 0 # <<<<<<<<<<<<<<
* stop = index.stop or 0
* step = index.step or 0
*/
/*else*/ {
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 760, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 760, __pyx_L1_error)
if (!__pyx_t_1) {
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
} else {
__pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 760, __pyx_L1_error)
__pyx_t_10 = __pyx_t_12;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L7_bool_binop_done;
}
__pyx_t_10 = 0;
__pyx_L7_bool_binop_done:;
__pyx_v_start = __pyx_t_10;
/* "View.MemoryView":761
* else:
* start = index.start or 0
* stop = index.stop or 0 # <<<<<<<<<<<<<<
* step = index.step or 0
*
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 761, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 761, __pyx_L1_error)
if (!__pyx_t_1) {
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
} else {
__pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 761, __pyx_L1_error)
__pyx_t_10 = __pyx_t_12;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L9_bool_binop_done;
}
__pyx_t_10 = 0;
__pyx_L9_bool_binop_done:;
__pyx_v_stop = __pyx_t_10;
/* "View.MemoryView":762
* start = index.start or 0
* stop = index.stop or 0
* step = index.step or 0 # <<<<<<<<<<<<<<
*
* have_start = index.start is not None
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 762, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 762, __pyx_L1_error)
if (!__pyx_t_1) {
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
} else {
__pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 762, __pyx_L1_error)
__pyx_t_10 = __pyx_t_12;
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
goto __pyx_L11_bool_binop_done;
}
__pyx_t_10 = 0;
__pyx_L11_bool_binop_done:;
__pyx_v_step = __pyx_t_10;
/* "View.MemoryView":764
* step = index.step or 0
*
* have_start = index.start is not None # <<<<<<<<<<<<<<
* have_stop = index.stop is not None
* have_step = index.step is not None
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 764, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = (__pyx_t_9 != Py_None);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_have_start = __pyx_t_1;
/* "View.MemoryView":765
*
* have_start = index.start is not None
* have_stop = index.stop is not None # <<<<<<<<<<<<<<
* have_step = index.step is not None
*
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 765, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = (__pyx_t_9 != Py_None);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_have_stop = __pyx_t_1;
/* "View.MemoryView":766
* have_start = index.start is not None
* have_stop = index.stop is not None
* have_step = index.step is not None # <<<<<<<<<<<<<<
*
* slice_memviewslice(
*/
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 766, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_1 = (__pyx_t_9 != Py_None);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_v_have_step = __pyx_t_1;
/* "View.MemoryView":768
* have_step = index.step is not None
*
* slice_memviewslice( # <<<<<<<<<<<<<<
* p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
* dim, new_ndim, p_suboffset_dim,
*/
__pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 768, __pyx_L1_error)
/* "View.MemoryView":774
* have_start, have_stop, have_step,
* True)
* new_ndim += 1 # <<<<<<<<<<<<<<
*
* if isinstance(memview, _memoryviewslice):
*/
__pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
}
__pyx_L6:;
/* "View.MemoryView":746
* cdef bint have_start, have_stop, have_step
*
* for dim, index in enumerate(indices): # <<<<<<<<<<<<<<
* if PyIndex_Check(index):
* slice_memviewslice(
*/
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":776
* new_ndim += 1
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func,
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":777
*
* if isinstance(memview, _memoryviewslice):
* return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<<
* memviewsliceobj.to_object_func,
* memviewsliceobj.to_dtype_func,
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
/* "View.MemoryView":778
* if isinstance(memview, _memoryviewslice):
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func, # <<<<<<<<<<<<<<
* memviewsliceobj.to_dtype_func,
* memview.dtype_is_object)
*/
if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 778, __pyx_L1_error) }
/* "View.MemoryView":779
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func,
* memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<<
* memview.dtype_is_object)
* else:
*/
if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 779, __pyx_L1_error) }
/* "View.MemoryView":777
*
* if isinstance(memview, _memoryviewslice):
* return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<<
* memviewsliceobj.to_object_func,
* memviewsliceobj.to_dtype_func,
*/
__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 777, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 777, __pyx_L1_error)
__pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
__pyx_t_3 = 0;
goto __pyx_L0;
/* "View.MemoryView":776
* new_ndim += 1
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* return memoryview_fromslice(dst, new_ndim,
* memviewsliceobj.to_object_func,
*/
}
/* "View.MemoryView":782
* memview.dtype_is_object)
* else:
* return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<<
* memview.dtype_is_object)
*
*/
/*else*/ {
__Pyx_XDECREF(((PyObject *)__pyx_r));
/* "View.MemoryView":783
* else:
* return memoryview_fromslice(dst, new_ndim, NULL, NULL,
* memview.dtype_is_object) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 782, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
/* "View.MemoryView":782
* memview.dtype_is_object)
* else:
* return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<<
* memview.dtype_is_object)
*
*/
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 782, __pyx_L1_error)
__pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
__pyx_t_3 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":710
*
* @cname('__pyx_memview_slice')
* cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<<
* cdef int new_ndim = 0, suboffset_dim = -1, dim
* cdef bint negative_step
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
__Pyx_XDECREF(__pyx_v_index);
__Pyx_XGIVEREF((PyObject *)__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":807
*
* @cname('__pyx_memoryview_slice_memviewslice')
* cdef int slice_memviewslice( # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
*/
static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) {
Py_ssize_t __pyx_v_new_shape;
int __pyx_v_negative_step;
int __pyx_r;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":827
* cdef bint negative_step
*
* if not is_slice: # <<<<<<<<<<<<<<
*
* if start < 0:
*/
__pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":829
* if not is_slice:
*
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if not 0 <= start < shape:
*/
__pyx_t_1 = ((__pyx_v_start < 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":830
*
* if start < 0:
* start += shape # <<<<<<<<<<<<<<
* if not 0 <= start < shape:
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
*/
__pyx_v_start = (__pyx_v_start + __pyx_v_shape);
/* "View.MemoryView":829
* if not is_slice:
*
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if not 0 <= start < shape:
*/
}
/* "View.MemoryView":831
* if start < 0:
* start += shape
* if not 0 <= start < shape: # <<<<<<<<<<<<<<
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
* else:
*/
__pyx_t_1 = (0 <= __pyx_v_start);
if (__pyx_t_1) {
__pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
}
__pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":832
* start += shape
* if not 0 <= start < shape:
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<<
* else:
*
*/
__pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 832, __pyx_L1_error)
/* "View.MemoryView":831
* if start < 0:
* start += shape
* if not 0 <= start < shape: # <<<<<<<<<<<<<<
* _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
* else:
*/
}
/* "View.MemoryView":827
* cdef bint negative_step
*
* if not is_slice: # <<<<<<<<<<<<<<
*
* if start < 0:
*/
goto __pyx_L3;
}
/* "View.MemoryView":835
* else:
*
* negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<<
*
* if have_step and step == 0:
*/
/*else*/ {
__pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
if (__pyx_t_1) {
} else {
__pyx_t_2 = __pyx_t_1;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_1 = ((__pyx_v_step < 0) != 0);
__pyx_t_2 = __pyx_t_1;
__pyx_L6_bool_binop_done:;
__pyx_v_negative_step = __pyx_t_2;
/* "View.MemoryView":837
* negative_step = have_step != 0 and step < 0
*
* if have_step and step == 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
*
*/
__pyx_t_1 = (__pyx_v_have_step != 0);
if (__pyx_t_1) {
} else {
__pyx_t_2 = __pyx_t_1;
goto __pyx_L9_bool_binop_done;
}
__pyx_t_1 = ((__pyx_v_step == 0) != 0);
__pyx_t_2 = __pyx_t_1;
__pyx_L9_bool_binop_done:;
if (__pyx_t_2) {
/* "View.MemoryView":838
*
* if have_step and step == 0:
* _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 838, __pyx_L1_error)
/* "View.MemoryView":837
* negative_step = have_step != 0 and step < 0
*
* if have_step and step == 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
*
*/
}
/* "View.MemoryView":841
*
*
* if have_start: # <<<<<<<<<<<<<<
* if start < 0:
* start += shape
*/
__pyx_t_2 = (__pyx_v_have_start != 0);
if (__pyx_t_2) {
/* "View.MemoryView":842
*
* if have_start:
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if start < 0:
*/
__pyx_t_2 = ((__pyx_v_start < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":843
* if have_start:
* if start < 0:
* start += shape # <<<<<<<<<<<<<<
* if start < 0:
* start = 0
*/
__pyx_v_start = (__pyx_v_start + __pyx_v_shape);
/* "View.MemoryView":844
* if start < 0:
* start += shape
* if start < 0: # <<<<<<<<<<<<<<
* start = 0
* elif start >= shape:
*/
__pyx_t_2 = ((__pyx_v_start < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":845
* start += shape
* if start < 0:
* start = 0 # <<<<<<<<<<<<<<
* elif start >= shape:
* if negative_step:
*/
__pyx_v_start = 0;
/* "View.MemoryView":844
* if start < 0:
* start += shape
* if start < 0: # <<<<<<<<<<<<<<
* start = 0
* elif start >= shape:
*/
}
/* "View.MemoryView":842
*
* if have_start:
* if start < 0: # <<<<<<<<<<<<<<
* start += shape
* if start < 0:
*/
goto __pyx_L12;
}
/* "View.MemoryView":846
* if start < 0:
* start = 0
* elif start >= shape: # <<<<<<<<<<<<<<
* if negative_step:
* start = shape - 1
*/
__pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":847
* start = 0
* elif start >= shape:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
__pyx_t_2 = (__pyx_v_negative_step != 0);
if (__pyx_t_2) {
/* "View.MemoryView":848
* elif start >= shape:
* if negative_step:
* start = shape - 1 # <<<<<<<<<<<<<<
* else:
* start = shape
*/
__pyx_v_start = (__pyx_v_shape - 1);
/* "View.MemoryView":847
* start = 0
* elif start >= shape:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
goto __pyx_L14;
}
/* "View.MemoryView":850
* start = shape - 1
* else:
* start = shape # <<<<<<<<<<<<<<
* else:
* if negative_step:
*/
/*else*/ {
__pyx_v_start = __pyx_v_shape;
}
__pyx_L14:;
/* "View.MemoryView":846
* if start < 0:
* start = 0
* elif start >= shape: # <<<<<<<<<<<<<<
* if negative_step:
* start = shape - 1
*/
}
__pyx_L12:;
/* "View.MemoryView":841
*
*
* if have_start: # <<<<<<<<<<<<<<
* if start < 0:
* start += shape
*/
goto __pyx_L11;
}
/* "View.MemoryView":852
* start = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
/*else*/ {
__pyx_t_2 = (__pyx_v_negative_step != 0);
if (__pyx_t_2) {
/* "View.MemoryView":853
* else:
* if negative_step:
* start = shape - 1 # <<<<<<<<<<<<<<
* else:
* start = 0
*/
__pyx_v_start = (__pyx_v_shape - 1);
/* "View.MemoryView":852
* start = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* start = shape - 1
* else:
*/
goto __pyx_L15;
}
/* "View.MemoryView":855
* start = shape - 1
* else:
* start = 0 # <<<<<<<<<<<<<<
*
* if have_stop:
*/
/*else*/ {
__pyx_v_start = 0;
}
__pyx_L15:;
}
__pyx_L11:;
/* "View.MemoryView":857
* start = 0
*
* if have_stop: # <<<<<<<<<<<<<<
* if stop < 0:
* stop += shape
*/
__pyx_t_2 = (__pyx_v_have_stop != 0);
if (__pyx_t_2) {
/* "View.MemoryView":858
*
* if have_stop:
* if stop < 0: # <<<<<<<<<<<<<<
* stop += shape
* if stop < 0:
*/
__pyx_t_2 = ((__pyx_v_stop < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":859
* if have_stop:
* if stop < 0:
* stop += shape # <<<<<<<<<<<<<<
* if stop < 0:
* stop = 0
*/
__pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
/* "View.MemoryView":860
* if stop < 0:
* stop += shape
* if stop < 0: # <<<<<<<<<<<<<<
* stop = 0
* elif stop > shape:
*/
__pyx_t_2 = ((__pyx_v_stop < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":861
* stop += shape
* if stop < 0:
* stop = 0 # <<<<<<<<<<<<<<
* elif stop > shape:
* stop = shape
*/
__pyx_v_stop = 0;
/* "View.MemoryView":860
* if stop < 0:
* stop += shape
* if stop < 0: # <<<<<<<<<<<<<<
* stop = 0
* elif stop > shape:
*/
}
/* "View.MemoryView":858
*
* if have_stop:
* if stop < 0: # <<<<<<<<<<<<<<
* stop += shape
* if stop < 0:
*/
goto __pyx_L17;
}
/* "View.MemoryView":862
* if stop < 0:
* stop = 0
* elif stop > shape: # <<<<<<<<<<<<<<
* stop = shape
* else:
*/
__pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":863
* stop = 0
* elif stop > shape:
* stop = shape # <<<<<<<<<<<<<<
* else:
* if negative_step:
*/
__pyx_v_stop = __pyx_v_shape;
/* "View.MemoryView":862
* if stop < 0:
* stop = 0
* elif stop > shape: # <<<<<<<<<<<<<<
* stop = shape
* else:
*/
}
__pyx_L17:;
/* "View.MemoryView":857
* start = 0
*
* if have_stop: # <<<<<<<<<<<<<<
* if stop < 0:
* stop += shape
*/
goto __pyx_L16;
}
/* "View.MemoryView":865
* stop = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* stop = -1
* else:
*/
/*else*/ {
__pyx_t_2 = (__pyx_v_negative_step != 0);
if (__pyx_t_2) {
/* "View.MemoryView":866
* else:
* if negative_step:
* stop = -1 # <<<<<<<<<<<<<<
* else:
* stop = shape
*/
__pyx_v_stop = -1L;
/* "View.MemoryView":865
* stop = shape
* else:
* if negative_step: # <<<<<<<<<<<<<<
* stop = -1
* else:
*/
goto __pyx_L19;
}
/* "View.MemoryView":868
* stop = -1
* else:
* stop = shape # <<<<<<<<<<<<<<
*
* if not have_step:
*/
/*else*/ {
__pyx_v_stop = __pyx_v_shape;
}
__pyx_L19:;
}
__pyx_L16:;
/* "View.MemoryView":870
* stop = shape
*
* if not have_step: # <<<<<<<<<<<<<<
* step = 1
*
*/
__pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":871
*
* if not have_step:
* step = 1 # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_step = 1;
/* "View.MemoryView":870
* stop = shape
*
* if not have_step: # <<<<<<<<<<<<<<
* step = 1
*
*/
}
/* "View.MemoryView":875
*
* with cython.cdivision(True):
* new_shape = (stop - start) // step # <<<<<<<<<<<<<<
*
* if (stop - start) - step * new_shape:
*/
__pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
/* "View.MemoryView":877
* new_shape = (stop - start) // step
*
* if (stop - start) - step * new_shape: # <<<<<<<<<<<<<<
* new_shape += 1
*
*/
__pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":878
*
* if (stop - start) - step * new_shape:
* new_shape += 1 # <<<<<<<<<<<<<<
*
* if new_shape < 0:
*/
__pyx_v_new_shape = (__pyx_v_new_shape + 1);
/* "View.MemoryView":877
* new_shape = (stop - start) // step
*
* if (stop - start) - step * new_shape: # <<<<<<<<<<<<<<
* new_shape += 1
*
*/
}
/* "View.MemoryView":880
* new_shape += 1
*
* if new_shape < 0: # <<<<<<<<<<<<<<
* new_shape = 0
*
*/
__pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":881
*
* if new_shape < 0:
* new_shape = 0 # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_new_shape = 0;
/* "View.MemoryView":880
* new_shape += 1
*
* if new_shape < 0: # <<<<<<<<<<<<<<
* new_shape = 0
*
*/
}
/* "View.MemoryView":884
*
*
* dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<<
* dst.shape[new_ndim] = new_shape
* dst.suboffsets[new_ndim] = suboffset
*/
(__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
/* "View.MemoryView":885
*
* dst.strides[new_ndim] = stride * step
* dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<<
* dst.suboffsets[new_ndim] = suboffset
*
*/
(__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
/* "View.MemoryView":886
* dst.strides[new_ndim] = stride * step
* dst.shape[new_ndim] = new_shape
* dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<<
*
*
*/
(__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
}
__pyx_L3:;
/* "View.MemoryView":889
*
*
* if suboffset_dim[0] < 0: # <<<<<<<<<<<<<<
* dst.data += start * stride
* else:
*/
__pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":890
*
* if suboffset_dim[0] < 0:
* dst.data += start * stride # <<<<<<<<<<<<<<
* else:
* dst.suboffsets[suboffset_dim[0]] += start * stride
*/
__pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
/* "View.MemoryView":889
*
*
* if suboffset_dim[0] < 0: # <<<<<<<<<<<<<<
* dst.data += start * stride
* else:
*/
goto __pyx_L23;
}
/* "View.MemoryView":892
* dst.data += start * stride
* else:
* dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<<
*
* if suboffset >= 0:
*/
/*else*/ {
__pyx_t_3 = (__pyx_v_suboffset_dim[0]);
(__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
}
__pyx_L23:;
/* "View.MemoryView":894
* dst.suboffsets[suboffset_dim[0]] += start * stride
*
* if suboffset >= 0: # <<<<<<<<<<<<<<
* if not is_slice:
* if new_ndim == 0:
*/
__pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":895
*
* if suboffset >= 0:
* if not is_slice: # <<<<<<<<<<<<<<
* if new_ndim == 0:
* dst.data = (<char **> dst.data)[0] + suboffset
*/
__pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":896
* if suboffset >= 0:
* if not is_slice:
* if new_ndim == 0: # <<<<<<<<<<<<<<
* dst.data = (<char **> dst.data)[0] + suboffset
* else:
*/
__pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":897
* if not is_slice:
* if new_ndim == 0:
* dst.data = (<char **> dst.data)[0] + suboffset # <<<<<<<<<<<<<<
* else:
* _err_dim(IndexError, "All dimensions preceding dimension %d "
*/
__pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
/* "View.MemoryView":896
* if suboffset >= 0:
* if not is_slice:
* if new_ndim == 0: # <<<<<<<<<<<<<<
* dst.data = (<char **> dst.data)[0] + suboffset
* else:
*/
goto __pyx_L26;
}
/* "View.MemoryView":899
* dst.data = (<char **> dst.data)[0] + suboffset
* else:
* _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<<
* "must be indexed and not sliced", dim)
* else:
*/
/*else*/ {
/* "View.MemoryView":900
* else:
* _err_dim(IndexError, "All dimensions preceding dimension %d "
* "must be indexed and not sliced", dim) # <<<<<<<<<<<<<<
* else:
* suboffset_dim[0] = new_ndim
*/
__pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 899, __pyx_L1_error)
}
__pyx_L26:;
/* "View.MemoryView":895
*
* if suboffset >= 0:
* if not is_slice: # <<<<<<<<<<<<<<
* if new_ndim == 0:
* dst.data = (<char **> dst.data)[0] + suboffset
*/
goto __pyx_L25;
}
/* "View.MemoryView":902
* "must be indexed and not sliced", dim)
* else:
* suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<<
*
* return 0
*/
/*else*/ {
(__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
}
__pyx_L25:;
/* "View.MemoryView":894
* dst.suboffsets[suboffset_dim[0]] += start * stride
*
* if suboffset >= 0: # <<<<<<<<<<<<<<
* if not is_slice:
* if new_ndim == 0:
*/
}
/* "View.MemoryView":904
* suboffset_dim[0] = new_ndim
*
* return 0 # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":807
*
* @cname('__pyx_memoryview_slice_memviewslice')
* cdef int slice_memviewslice( # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = -1;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":910
*
* @cname('__pyx_pybuffer_index')
* cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<<
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1
*/
static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) {
Py_ssize_t __pyx_v_shape;
Py_ssize_t __pyx_v_stride;
Py_ssize_t __pyx_v_suboffset;
Py_ssize_t __pyx_v_itemsize;
char *__pyx_v_resultp;
char *__pyx_r;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("pybuffer_index", 0);
/* "View.MemoryView":912
* cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<<
* cdef Py_ssize_t itemsize = view.itemsize
* cdef char *resultp
*/
__pyx_v_suboffset = -1L;
/* "View.MemoryView":913
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1
* cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<<
* cdef char *resultp
*
*/
__pyx_t_1 = __pyx_v_view->itemsize;
__pyx_v_itemsize = __pyx_t_1;
/* "View.MemoryView":916
* cdef char *resultp
*
* if view.ndim == 0: # <<<<<<<<<<<<<<
* shape = view.len / itemsize
* stride = itemsize
*/
__pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":917
*
* if view.ndim == 0:
* shape = view.len / itemsize # <<<<<<<<<<<<<<
* stride = itemsize
* else:
*/
if (unlikely(__pyx_v_itemsize == 0)) {
PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
__PYX_ERR(1, 917, __pyx_L1_error)
}
else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) {
PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
__PYX_ERR(1, 917, __pyx_L1_error)
}
__pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
/* "View.MemoryView":918
* if view.ndim == 0:
* shape = view.len / itemsize
* stride = itemsize # <<<<<<<<<<<<<<
* else:
* shape = view.shape[dim]
*/
__pyx_v_stride = __pyx_v_itemsize;
/* "View.MemoryView":916
* cdef char *resultp
*
* if view.ndim == 0: # <<<<<<<<<<<<<<
* shape = view.len / itemsize
* stride = itemsize
*/
goto __pyx_L3;
}
/* "View.MemoryView":920
* stride = itemsize
* else:
* shape = view.shape[dim] # <<<<<<<<<<<<<<
* stride = view.strides[dim]
* if view.suboffsets != NULL:
*/
/*else*/ {
__pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
/* "View.MemoryView":921
* else:
* shape = view.shape[dim]
* stride = view.strides[dim] # <<<<<<<<<<<<<<
* if view.suboffsets != NULL:
* suboffset = view.suboffsets[dim]
*/
__pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
/* "View.MemoryView":922
* shape = view.shape[dim]
* stride = view.strides[dim]
* if view.suboffsets != NULL: # <<<<<<<<<<<<<<
* suboffset = view.suboffsets[dim]
*
*/
__pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":923
* stride = view.strides[dim]
* if view.suboffsets != NULL:
* suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<<
*
* if index < 0:
*/
__pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
/* "View.MemoryView":922
* shape = view.shape[dim]
* stride = view.strides[dim]
* if view.suboffsets != NULL: # <<<<<<<<<<<<<<
* suboffset = view.suboffsets[dim]
*
*/
}
}
__pyx_L3:;
/* "View.MemoryView":925
* suboffset = view.suboffsets[dim]
*
* if index < 0: # <<<<<<<<<<<<<<
* index += view.shape[dim]
* if index < 0:
*/
__pyx_t_2 = ((__pyx_v_index < 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":926
*
* if index < 0:
* index += view.shape[dim] # <<<<<<<<<<<<<<
* if index < 0:
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*/
__pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
/* "View.MemoryView":927
* if index < 0:
* index += view.shape[dim]
* if index < 0: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
__pyx_t_2 = ((__pyx_v_index < 0) != 0);
if (unlikely(__pyx_t_2)) {
/* "View.MemoryView":928
* index += view.shape[dim]
* if index < 0:
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<<
*
* if index >= shape:
*/
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 928, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 928, __pyx_L1_error)
/* "View.MemoryView":927
* if index < 0:
* index += view.shape[dim]
* if index < 0: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
}
/* "View.MemoryView":925
* suboffset = view.suboffsets[dim]
*
* if index < 0: # <<<<<<<<<<<<<<
* index += view.shape[dim]
* if index < 0:
*/
}
/* "View.MemoryView":930
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
* if index >= shape: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
__pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
if (unlikely(__pyx_t_2)) {
/* "View.MemoryView":931
*
* if index >= shape:
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<<
*
* resultp = bufp + index * stride
*/
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 931, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 931, __pyx_L1_error)
/* "View.MemoryView":930
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
* if index >= shape: # <<<<<<<<<<<<<<
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
*/
}
/* "View.MemoryView":933
* raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
*
* resultp = bufp + index * stride # <<<<<<<<<<<<<<
* if suboffset >= 0:
* resultp = (<char **> resultp)[0] + suboffset
*/
__pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
/* "View.MemoryView":934
*
* resultp = bufp + index * stride
* if suboffset >= 0: # <<<<<<<<<<<<<<
* resultp = (<char **> resultp)[0] + suboffset
*
*/
__pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":935
* resultp = bufp + index * stride
* if suboffset >= 0:
* resultp = (<char **> resultp)[0] + suboffset # <<<<<<<<<<<<<<
*
* return resultp
*/
__pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
/* "View.MemoryView":934
*
* resultp = bufp + index * stride
* if suboffset >= 0: # <<<<<<<<<<<<<<
* resultp = (<char **> resultp)[0] + suboffset
*
*/
}
/* "View.MemoryView":937
* resultp = (<char **> resultp)[0] + suboffset
*
* return resultp # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_resultp;
goto __pyx_L0;
/* "View.MemoryView":910
*
* @cname('__pyx_pybuffer_index')
* cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<<
* Py_ssize_t dim) except NULL:
* cdef Py_ssize_t shape, stride, suboffset = -1
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":943
*
* @cname('__pyx_memslice_transpose')
* cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<<
* cdef int ndim = memslice.memview.view.ndim
*
*/
static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
int __pyx_v_ndim;
Py_ssize_t *__pyx_v_shape;
Py_ssize_t *__pyx_v_strides;
int __pyx_v_i;
int __pyx_v_j;
int __pyx_r;
int __pyx_t_1;
Py_ssize_t *__pyx_t_2;
long __pyx_t_3;
long __pyx_t_4;
Py_ssize_t __pyx_t_5;
Py_ssize_t __pyx_t_6;
int __pyx_t_7;
int __pyx_t_8;
int __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":944
* @cname('__pyx_memslice_transpose')
* cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
* cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<<
*
* cdef Py_ssize_t *shape = memslice.shape
*/
__pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
__pyx_v_ndim = __pyx_t_1;
/* "View.MemoryView":946
* cdef int ndim = memslice.memview.view.ndim
*
* cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<<
* cdef Py_ssize_t *strides = memslice.strides
*
*/
__pyx_t_2 = __pyx_v_memslice->shape;
__pyx_v_shape = __pyx_t_2;
/* "View.MemoryView":947
*
* cdef Py_ssize_t *shape = memslice.shape
* cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = __pyx_v_memslice->strides;
__pyx_v_strides = __pyx_t_2;
/* "View.MemoryView":951
*
* cdef int i, j
* for i in range(ndim / 2): # <<<<<<<<<<<<<<
* j = ndim - 1 - i
* strides[i], strides[j] = strides[j], strides[i]
*/
__pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
__pyx_t_4 = __pyx_t_3;
for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":952
* cdef int i, j
* for i in range(ndim / 2):
* j = ndim - 1 - i # <<<<<<<<<<<<<<
* strides[i], strides[j] = strides[j], strides[i]
* shape[i], shape[j] = shape[j], shape[i]
*/
__pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
/* "View.MemoryView":953
* for i in range(ndim / 2):
* j = ndim - 1 - i
* strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<<
* shape[i], shape[j] = shape[j], shape[i]
*
*/
__pyx_t_5 = (__pyx_v_strides[__pyx_v_j]);
__pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
(__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
(__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
/* "View.MemoryView":954
* j = ndim - 1 - i
* strides[i], strides[j] = strides[j], strides[i]
* shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<<
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
*/
__pyx_t_6 = (__pyx_v_shape[__pyx_v_j]);
__pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
(__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
(__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
/* "View.MemoryView":956
* shape[i], shape[j] = shape[j], shape[i]
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<<
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
*
*/
__pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
if (!__pyx_t_8) {
} else {
__pyx_t_7 = __pyx_t_8;
goto __pyx_L6_bool_binop_done;
}
__pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
__pyx_t_7 = __pyx_t_8;
__pyx_L6_bool_binop_done:;
if (__pyx_t_7) {
/* "View.MemoryView":957
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<<
*
* return 1
*/
__pyx_t_9 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L1_error)
/* "View.MemoryView":956
* shape[i], shape[j] = shape[j], shape[i]
*
* if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<<
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
*
*/
}
}
/* "View.MemoryView":959
* _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
*
* return 1 # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = 1;
goto __pyx_L0;
/* "View.MemoryView":943
*
* @cname('__pyx_memslice_transpose')
* cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<<
* cdef int ndim = memslice.memview.view.ndim
*
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":976
* cdef int (*to_dtype_func)(char *, object) except 0
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
*/
/* Python wrapper */
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
__pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
}
static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
/* "View.MemoryView":977
*
* def __dealloc__(self):
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<<
*
* cdef convert_item_to_object(self, char *itemp):
*/
__PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
/* "View.MemoryView":976
* cdef int (*to_dtype_func)(char *, object) except 0
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":979
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* if self.to_object_func != NULL:
* return self.to_object_func(itemp)
*/
static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("convert_item_to_object", 0);
/* "View.MemoryView":980
*
* cdef convert_item_to_object(self, char *itemp):
* if self.to_object_func != NULL: # <<<<<<<<<<<<<<
* return self.to_object_func(itemp)
* else:
*/
__pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":981
* cdef convert_item_to_object(self, char *itemp):
* if self.to_object_func != NULL:
* return self.to_object_func(itemp) # <<<<<<<<<<<<<<
* else:
* return memoryview.convert_item_to_object(self, itemp)
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 981, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* "View.MemoryView":980
*
* cdef convert_item_to_object(self, char *itemp):
* if self.to_object_func != NULL: # <<<<<<<<<<<<<<
* return self.to_object_func(itemp)
* else:
*/
}
/* "View.MemoryView":983
* return self.to_object_func(itemp)
* else:
* return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<<
*
* cdef assign_item_from_object(self, char *itemp, object value):
*/
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 983, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
}
/* "View.MemoryView":979
* __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
*
* cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
* if self.to_object_func != NULL:
* return self.to_object_func(itemp)
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":985
* return memoryview.convert_item_to_object(self, itemp)
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* if self.to_dtype_func != NULL:
* self.to_dtype_func(itemp, value)
*/
static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("assign_item_from_object", 0);
/* "View.MemoryView":986
*
* cdef assign_item_from_object(self, char *itemp, object value):
* if self.to_dtype_func != NULL: # <<<<<<<<<<<<<<
* self.to_dtype_func(itemp, value)
* else:
*/
__pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":987
* cdef assign_item_from_object(self, char *itemp, object value):
* if self.to_dtype_func != NULL:
* self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<<
* else:
* memoryview.assign_item_from_object(self, itemp, value)
*/
__pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 987, __pyx_L1_error)
/* "View.MemoryView":986
*
* cdef assign_item_from_object(self, char *itemp, object value):
* if self.to_dtype_func != NULL: # <<<<<<<<<<<<<<
* self.to_dtype_func(itemp, value)
* else:
*/
goto __pyx_L3;
}
/* "View.MemoryView":989
* self.to_dtype_func(itemp, value)
* else:
* memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<<
*
* @property
*/
/*else*/ {
__pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 989, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_L3:;
/* "View.MemoryView":985
* return memoryview.convert_item_to_object(self, itemp)
*
* cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
* if self.to_dtype_func != NULL:
* self.to_dtype_func(itemp, value)
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":992
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.from_object
*
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
__pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get__", 0);
/* "View.MemoryView":993
* @property
* def base(self):
* return self.from_object # <<<<<<<<<<<<<<
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_self->from_object);
__pyx_r = __pyx_v_self->from_object;
goto __pyx_L0;
/* "View.MemoryView":992
*
* @property
* def base(self): # <<<<<<<<<<<<<<
* return self.from_object
*
*/
/* function exit code */
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 2, __pyx_L1_error)
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* Python wrapper */
static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
__pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 4, __pyx_L1_error)
/* "(tree fragment)":3
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":999
*
* @cname('__pyx_memoryview_fromslice')
* cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<<
* int ndim,
* object (*to_object_func)(char *),
*/
static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) {
struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
Py_ssize_t __pyx_v_suboffset;
PyObject *__pyx_v_length = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
__Pyx_TypeInfo *__pyx_t_4;
Py_buffer __pyx_t_5;
Py_ssize_t *__pyx_t_6;
Py_ssize_t *__pyx_t_7;
Py_ssize_t *__pyx_t_8;
Py_ssize_t __pyx_t_9;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_fromslice", 0);
/* "View.MemoryView":1007
* cdef _memoryviewslice result
*
* if <PyObject *> memviewslice.memview == Py_None: # <<<<<<<<<<<<<<
* return None
*
*/
__pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1008
*
* if <PyObject *> memviewslice.memview == Py_None:
* return None # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
/* "View.MemoryView":1007
* cdef _memoryviewslice result
*
* if <PyObject *> memviewslice.memview == Py_None: # <<<<<<<<<<<<<<
* return None
*
*/
}
/* "View.MemoryView":1013
*
*
* result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<<
*
* result.from_slice = memviewslice
*/
__pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1013, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
__Pyx_INCREF(__pyx_int_0);
__Pyx_GIVEREF(__pyx_int_0);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
__pyx_t_2 = 0;
/* "View.MemoryView":1015
* result = _memoryviewslice(None, 0, dtype_is_object)
*
* result.from_slice = memviewslice # <<<<<<<<<<<<<<
* __PYX_INC_MEMVIEW(&memviewslice, 1)
*
*/
__pyx_v_result->from_slice = __pyx_v_memviewslice;
/* "View.MemoryView":1016
*
* result.from_slice = memviewslice
* __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<<
*
* result.from_object = (<memoryview> memviewslice.memview).base
*/
__PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
/* "View.MemoryView":1018
* __PYX_INC_MEMVIEW(&memviewslice, 1)
*
* result.from_object = (<memoryview> memviewslice.memview).base # <<<<<<<<<<<<<<
* result.typeinfo = memviewslice.memview.typeinfo
*
*/
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1018, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__Pyx_GOTREF(__pyx_v_result->from_object);
__Pyx_DECREF(__pyx_v_result->from_object);
__pyx_v_result->from_object = __pyx_t_2;
__pyx_t_2 = 0;
/* "View.MemoryView":1019
*
* result.from_object = (<memoryview> memviewslice.memview).base
* result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<<
*
* result.view = memviewslice.memview.view
*/
__pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
__pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
/* "View.MemoryView":1021
* result.typeinfo = memviewslice.memview.typeinfo
*
* result.view = memviewslice.memview.view # <<<<<<<<<<<<<<
* result.view.buf = <void *> memviewslice.data
* result.view.ndim = ndim
*/
__pyx_t_5 = __pyx_v_memviewslice.memview->view;
__pyx_v_result->__pyx_base.view = __pyx_t_5;
/* "View.MemoryView":1022
*
* result.view = memviewslice.memview.view
* result.view.buf = <void *> memviewslice.data # <<<<<<<<<<<<<<
* result.view.ndim = ndim
* (<__pyx_buffer *> &result.view).obj = Py_None
*/
__pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
/* "View.MemoryView":1023
* result.view = memviewslice.memview.view
* result.view.buf = <void *> memviewslice.data
* result.view.ndim = ndim # <<<<<<<<<<<<<<
* (<__pyx_buffer *> &result.view).obj = Py_None
* Py_INCREF(Py_None)
*/
__pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
/* "View.MemoryView":1024
* result.view.buf = <void *> memviewslice.data
* result.view.ndim = ndim
* (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<<
* Py_INCREF(Py_None)
*
*/
((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
/* "View.MemoryView":1025
* result.view.ndim = ndim
* (<__pyx_buffer *> &result.view).obj = Py_None
* Py_INCREF(Py_None) # <<<<<<<<<<<<<<
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
*/
Py_INCREF(Py_None);
/* "View.MemoryView":1027
* Py_INCREF(Py_None)
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<<
* result.flags = PyBUF_RECORDS
* else:
*/
__pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1028
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
* result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<<
* else:
* result.flags = PyBUF_RECORDS_RO
*/
__pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
/* "View.MemoryView":1027
* Py_INCREF(Py_None)
*
* if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<<
* result.flags = PyBUF_RECORDS
* else:
*/
goto __pyx_L4;
}
/* "View.MemoryView":1030
* result.flags = PyBUF_RECORDS
* else:
* result.flags = PyBUF_RECORDS_RO # <<<<<<<<<<<<<<
*
* result.view.shape = <Py_ssize_t *> result.from_slice.shape
*/
/*else*/ {
__pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
}
__pyx_L4:;
/* "View.MemoryView":1032
* result.flags = PyBUF_RECORDS_RO
*
* result.view.shape = <Py_ssize_t *> result.from_slice.shape # <<<<<<<<<<<<<<
* result.view.strides = <Py_ssize_t *> result.from_slice.strides
*
*/
__pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
/* "View.MemoryView":1033
*
* result.view.shape = <Py_ssize_t *> result.from_slice.shape
* result.view.strides = <Py_ssize_t *> result.from_slice.strides # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
/* "View.MemoryView":1036
*
*
* result.view.suboffsets = NULL # <<<<<<<<<<<<<<
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0:
*/
__pyx_v_result->__pyx_base.view.suboffsets = NULL;
/* "View.MemoryView":1037
*
* result.view.suboffsets = NULL
* for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<<
* if suboffset >= 0:
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
*/
__pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
__pyx_t_6 = __pyx_t_8;
__pyx_v_suboffset = (__pyx_t_6[0]);
/* "View.MemoryView":1038
* result.view.suboffsets = NULL
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
* break
*/
__pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1039
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0:
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets # <<<<<<<<<<<<<<
* break
*
*/
__pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
/* "View.MemoryView":1040
* if suboffset >= 0:
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
* break # <<<<<<<<<<<<<<
*
* result.view.len = result.view.itemsize
*/
goto __pyx_L6_break;
/* "View.MemoryView":1038
* result.view.suboffsets = NULL
* for suboffset in result.from_slice.suboffsets[:ndim]:
* if suboffset >= 0: # <<<<<<<<<<<<<<
* result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
* break
*/
}
}
__pyx_L6_break:;
/* "View.MemoryView":1042
* break
*
* result.view.len = result.view.itemsize # <<<<<<<<<<<<<<
* for length in result.view.shape[:ndim]:
* result.view.len *= length
*/
__pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
__pyx_v_result->__pyx_base.view.len = __pyx_t_9;
/* "View.MemoryView":1043
*
* result.view.len = result.view.itemsize
* for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<<
* result.view.len *= length
*
*/
__pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
__pyx_t_6 = __pyx_t_8;
__pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1043, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
__pyx_t_2 = 0;
/* "View.MemoryView":1044
* result.view.len = result.view.itemsize
* for length in result.view.shape[:ndim]:
* result.view.len *= length # <<<<<<<<<<<<<<
*
* result.to_object_func = to_object_func
*/
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1044, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1044, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1044, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_result->__pyx_base.view.len = __pyx_t_9;
}
/* "View.MemoryView":1046
* result.view.len *= length
*
* result.to_object_func = to_object_func # <<<<<<<<<<<<<<
* result.to_dtype_func = to_dtype_func
*
*/
__pyx_v_result->to_object_func = __pyx_v_to_object_func;
/* "View.MemoryView":1047
*
* result.to_object_func = to_object_func
* result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<<
*
* return result
*/
__pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
/* "View.MemoryView":1049
* result.to_dtype_func = to_dtype_func
*
* return result # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_get_slice_from_memoryview')
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(((PyObject *)__pyx_v_result));
__pyx_r = ((PyObject *)__pyx_v_result);
goto __pyx_L0;
/* "View.MemoryView":999
*
* @cname('__pyx_memoryview_fromslice')
* cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<<
* int ndim,
* object (*to_object_func)(char *),
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_result);
__Pyx_XDECREF(__pyx_v_length);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1052
*
* @cname('__pyx_memoryview_get_slice_from_memoryview')
* cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *mslice) except NULL:
* cdef _memoryviewslice obj
*/
static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
__Pyx_memviewslice *__pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("get_slice_from_memview", 0);
/* "View.MemoryView":1055
* __Pyx_memviewslice *mslice) except NULL:
* cdef _memoryviewslice obj
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* obj = memview
* return &obj.from_slice
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1056
* cdef _memoryviewslice obj
* if isinstance(memview, _memoryviewslice):
* obj = memview # <<<<<<<<<<<<<<
* return &obj.from_slice
* else:
*/
if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 1056, __pyx_L1_error)
__pyx_t_3 = ((PyObject *)__pyx_v_memview);
__Pyx_INCREF(__pyx_t_3);
__pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":1057
* if isinstance(memview, _memoryviewslice):
* obj = memview
* return &obj.from_slice # <<<<<<<<<<<<<<
* else:
* slice_copy(memview, mslice)
*/
__pyx_r = (&__pyx_v_obj->from_slice);
goto __pyx_L0;
/* "View.MemoryView":1055
* __Pyx_memviewslice *mslice) except NULL:
* cdef _memoryviewslice obj
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* obj = memview
* return &obj.from_slice
*/
}
/* "View.MemoryView":1059
* return &obj.from_slice
* else:
* slice_copy(memview, mslice) # <<<<<<<<<<<<<<
* return mslice
*
*/
/*else*/ {
__pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
/* "View.MemoryView":1060
* else:
* slice_copy(memview, mslice)
* return mslice # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_slice_copy')
*/
__pyx_r = __pyx_v_mslice;
goto __pyx_L0;
}
/* "View.MemoryView":1052
*
* @cname('__pyx_memoryview_get_slice_from_memoryview')
* cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *mslice) except NULL:
* cdef _memoryviewslice obj
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_obj);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1063
*
* @cname('__pyx_memoryview_slice_copy')
* cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<<
* cdef int dim
* cdef (Py_ssize_t*) shape, strides, suboffsets
*/
static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
int __pyx_v_dim;
Py_ssize_t *__pyx_v_shape;
Py_ssize_t *__pyx_v_strides;
Py_ssize_t *__pyx_v_suboffsets;
__Pyx_RefNannyDeclarations
Py_ssize_t *__pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
Py_ssize_t __pyx_t_5;
__Pyx_RefNannySetupContext("slice_copy", 0);
/* "View.MemoryView":1067
* cdef (Py_ssize_t*) shape, strides, suboffsets
*
* shape = memview.view.shape # <<<<<<<<<<<<<<
* strides = memview.view.strides
* suboffsets = memview.view.suboffsets
*/
__pyx_t_1 = __pyx_v_memview->view.shape;
__pyx_v_shape = __pyx_t_1;
/* "View.MemoryView":1068
*
* shape = memview.view.shape
* strides = memview.view.strides # <<<<<<<<<<<<<<
* suboffsets = memview.view.suboffsets
*
*/
__pyx_t_1 = __pyx_v_memview->view.strides;
__pyx_v_strides = __pyx_t_1;
/* "View.MemoryView":1069
* shape = memview.view.shape
* strides = memview.view.strides
* suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<<
*
* dst.memview = <__pyx_memoryview *> memview
*/
__pyx_t_1 = __pyx_v_memview->view.suboffsets;
__pyx_v_suboffsets = __pyx_t_1;
/* "View.MemoryView":1071
* suboffsets = memview.view.suboffsets
*
* dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<<
* dst.data = <char *> memview.view.buf
*
*/
__pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
/* "View.MemoryView":1072
*
* dst.memview = <__pyx_memoryview *> memview
* dst.data = <char *> memview.view.buf # <<<<<<<<<<<<<<
*
* for dim in range(memview.view.ndim):
*/
__pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
/* "View.MemoryView":1074
* dst.data = <char *> memview.view.buf
*
* for dim in range(memview.view.ndim): # <<<<<<<<<<<<<<
* dst.shape[dim] = shape[dim]
* dst.strides[dim] = strides[dim]
*/
__pyx_t_2 = __pyx_v_memview->view.ndim;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_dim = __pyx_t_4;
/* "View.MemoryView":1075
*
* for dim in range(memview.view.ndim):
* dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<<
* dst.strides[dim] = strides[dim]
* dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
*/
(__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
/* "View.MemoryView":1076
* for dim in range(memview.view.ndim):
* dst.shape[dim] = shape[dim]
* dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<<
* dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
*
*/
(__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
/* "View.MemoryView":1077
* dst.shape[dim] = shape[dim]
* dst.strides[dim] = strides[dim]
* dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_object')
*/
if ((__pyx_v_suboffsets != 0)) {
__pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
} else {
__pyx_t_5 = -1L;
}
(__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
}
/* "View.MemoryView":1063
*
* @cname('__pyx_memoryview_slice_copy')
* cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<<
* cdef int dim
* cdef (Py_ssize_t*) shape, strides, suboffsets
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":1080
*
* @cname('__pyx_memoryview_copy_object')
* cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<<
* "Create a new memoryview object"
* cdef __Pyx_memviewslice memviewslice
*/
static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
__Pyx_memviewslice __pyx_v_memviewslice;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_copy", 0);
/* "View.MemoryView":1083
* "Create a new memoryview object"
* cdef __Pyx_memviewslice memviewslice
* slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<<
* return memoryview_copy_from_slice(memview, &memviewslice)
*
*/
__pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
/* "View.MemoryView":1084
* cdef __Pyx_memviewslice memviewslice
* slice_copy(memview, &memviewslice)
* return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_object_from_slice')
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1084, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "View.MemoryView":1080
*
* @cname('__pyx_memoryview_copy_object')
* cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<<
* "Create a new memoryview object"
* cdef __Pyx_memviewslice memviewslice
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1087
*
* @cname('__pyx_memoryview_copy_object_from_slice')
* cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<<
* """
* Create a new memoryview object from a given memoryview object and slice.
*/
static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
PyObject *(*__pyx_v_to_object_func)(char *);
int (*__pyx_v_to_dtype_func)(char *, PyObject *);
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
int __pyx_t_2;
PyObject *(*__pyx_t_3)(char *);
int (*__pyx_t_4)(char *, PyObject *);
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
/* "View.MemoryView":1094
* cdef int (*to_dtype_func)(char *, object) except 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* to_object_func = (<_memoryviewslice> memview).to_object_func
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
*/
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
__pyx_t_2 = (__pyx_t_1 != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1095
*
* if isinstance(memview, _memoryviewslice):
* to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<<
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
* else:
*/
__pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
__pyx_v_to_object_func = __pyx_t_3;
/* "View.MemoryView":1096
* if isinstance(memview, _memoryviewslice):
* to_object_func = (<_memoryviewslice> memview).to_object_func
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<<
* else:
* to_object_func = NULL
*/
__pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
__pyx_v_to_dtype_func = __pyx_t_4;
/* "View.MemoryView":1094
* cdef int (*to_dtype_func)(char *, object) except 0
*
* if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
* to_object_func = (<_memoryviewslice> memview).to_object_func
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
*/
goto __pyx_L3;
}
/* "View.MemoryView":1098
* to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
* else:
* to_object_func = NULL # <<<<<<<<<<<<<<
* to_dtype_func = NULL
*
*/
/*else*/ {
__pyx_v_to_object_func = NULL;
/* "View.MemoryView":1099
* else:
* to_object_func = NULL
* to_dtype_func = NULL # <<<<<<<<<<<<<<
*
* return memoryview_fromslice(memviewslice[0], memview.view.ndim,
*/
__pyx_v_to_dtype_func = NULL;
}
__pyx_L3:;
/* "View.MemoryView":1101
* to_dtype_func = NULL
*
* return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<<
* to_object_func, to_dtype_func,
* memview.dtype_is_object)
*/
__Pyx_XDECREF(__pyx_r);
/* "View.MemoryView":1103
* return memoryview_fromslice(memviewslice[0], memview.view.ndim,
* to_object_func, to_dtype_func,
* memview.dtype_is_object) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
/* "View.MemoryView":1087
*
* @cname('__pyx_memoryview_copy_object_from_slice')
* cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<<
* """
* Create a new memoryview object from a given memoryview object and slice.
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "View.MemoryView":1109
*
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<<
* if arg < 0:
* return -arg
*/
static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
Py_ssize_t __pyx_r;
int __pyx_t_1;
/* "View.MemoryView":1110
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
* if arg < 0: # <<<<<<<<<<<<<<
* return -arg
* else:
*/
__pyx_t_1 = ((__pyx_v_arg < 0) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1111
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
* if arg < 0:
* return -arg # <<<<<<<<<<<<<<
* else:
* return arg
*/
__pyx_r = (-__pyx_v_arg);
goto __pyx_L0;
/* "View.MemoryView":1110
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
* if arg < 0: # <<<<<<<<<<<<<<
* return -arg
* else:
*/
}
/* "View.MemoryView":1113
* return -arg
* else:
* return arg # <<<<<<<<<<<<<<
*
* @cname('__pyx_get_best_slice_order')
*/
/*else*/ {
__pyx_r = __pyx_v_arg;
goto __pyx_L0;
}
/* "View.MemoryView":1109
*
*
* cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<<
* if arg < 0:
* return -arg
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1116
*
* @cname('__pyx_get_best_slice_order')
* cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<<
* """
* Figure out the best memory access order for a given slice.
*/
static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
int __pyx_v_i;
Py_ssize_t __pyx_v_c_stride;
Py_ssize_t __pyx_v_f_stride;
char __pyx_r;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
/* "View.MemoryView":1121
* """
* cdef int i
* cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<<
* cdef Py_ssize_t f_stride = 0
*
*/
__pyx_v_c_stride = 0;
/* "View.MemoryView":1122
* cdef int i
* cdef Py_ssize_t c_stride = 0
* cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<<
*
* for i in range(ndim - 1, -1, -1):
*/
__pyx_v_f_stride = 0;
/* "View.MemoryView":1124
* cdef Py_ssize_t f_stride = 0
*
* for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
* if mslice.shape[i] > 1:
* c_stride = mslice.strides[i]
*/
for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":1125
*
* for i in range(ndim - 1, -1, -1):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* c_stride = mslice.strides[i]
* break
*/
__pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1126
* for i in range(ndim - 1, -1, -1):
* if mslice.shape[i] > 1:
* c_stride = mslice.strides[i] # <<<<<<<<<<<<<<
* break
*
*/
__pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
/* "View.MemoryView":1127
* if mslice.shape[i] > 1:
* c_stride = mslice.strides[i]
* break # <<<<<<<<<<<<<<
*
* for i in range(ndim):
*/
goto __pyx_L4_break;
/* "View.MemoryView":1125
*
* for i in range(ndim - 1, -1, -1):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* c_stride = mslice.strides[i]
* break
*/
}
}
__pyx_L4_break:;
/* "View.MemoryView":1129
* break
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if mslice.shape[i] > 1:
* f_stride = mslice.strides[i]
*/
__pyx_t_1 = __pyx_v_ndim;
__pyx_t_3 = __pyx_t_1;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1130
*
* for i in range(ndim):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* f_stride = mslice.strides[i]
* break
*/
__pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1131
* for i in range(ndim):
* if mslice.shape[i] > 1:
* f_stride = mslice.strides[i] # <<<<<<<<<<<<<<
* break
*
*/
__pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
/* "View.MemoryView":1132
* if mslice.shape[i] > 1:
* f_stride = mslice.strides[i]
* break # <<<<<<<<<<<<<<
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
*/
goto __pyx_L7_break;
/* "View.MemoryView":1130
*
* for i in range(ndim):
* if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
* f_stride = mslice.strides[i]
* break
*/
}
}
__pyx_L7_break:;
/* "View.MemoryView":1134
* break
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<<
* return 'C'
* else:
*/
__pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1135
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
* return 'C' # <<<<<<<<<<<<<<
* else:
* return 'F'
*/
__pyx_r = 'C';
goto __pyx_L0;
/* "View.MemoryView":1134
* break
*
* if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<<
* return 'C'
* else:
*/
}
/* "View.MemoryView":1137
* return 'C'
* else:
* return 'F' # <<<<<<<<<<<<<<
*
* @cython.cdivision(True)
*/
/*else*/ {
__pyx_r = 'F';
goto __pyx_L0;
}
/* "View.MemoryView":1116
*
* @cname('__pyx_get_best_slice_order')
* cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<<
* """
* Figure out the best memory access order for a given slice.
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1140
*
* @cython.cdivision(True)
* cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<<
* char *dst_data, Py_ssize_t *dst_strides,
* Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
*/
static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
CYTHON_UNUSED Py_ssize_t __pyx_v_i;
CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
Py_ssize_t __pyx_v_dst_extent;
Py_ssize_t __pyx_v_src_stride;
Py_ssize_t __pyx_v_dst_stride;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
Py_ssize_t __pyx_t_4;
Py_ssize_t __pyx_t_5;
Py_ssize_t __pyx_t_6;
/* "View.MemoryView":1147
*
* cdef Py_ssize_t i
* cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t dst_extent = dst_shape[0]
* cdef Py_ssize_t src_stride = src_strides[0]
*/
__pyx_v_src_extent = (__pyx_v_src_shape[0]);
/* "View.MemoryView":1148
* cdef Py_ssize_t i
* cdef Py_ssize_t src_extent = src_shape[0]
* cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t src_stride = src_strides[0]
* cdef Py_ssize_t dst_stride = dst_strides[0]
*/
__pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
/* "View.MemoryView":1149
* cdef Py_ssize_t src_extent = src_shape[0]
* cdef Py_ssize_t dst_extent = dst_shape[0]
* cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t dst_stride = dst_strides[0]
*
*/
__pyx_v_src_stride = (__pyx_v_src_strides[0]);
/* "View.MemoryView":1150
* cdef Py_ssize_t dst_extent = dst_shape[0]
* cdef Py_ssize_t src_stride = src_strides[0]
* cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<<
*
* if ndim == 1:
*/
__pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
/* "View.MemoryView":1152
* cdef Py_ssize_t dst_stride = dst_strides[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride):
*/
__pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1153
*
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent)
*/
__pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L5_bool_binop_done;
}
__pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L5_bool_binop_done;
}
/* "View.MemoryView":1154
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride): # <<<<<<<<<<<<<<
* memcpy(dst_data, src_data, itemsize * dst_extent)
* else:
*/
__pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
if (__pyx_t_2) {
__pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
}
__pyx_t_3 = (__pyx_t_2 != 0);
__pyx_t_1 = __pyx_t_3;
__pyx_L5_bool_binop_done:;
/* "View.MemoryView":1153
*
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent)
*/
if (__pyx_t_1) {
/* "View.MemoryView":1155
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<<
* else:
* for i in range(dst_extent):
*/
(void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
/* "View.MemoryView":1153
*
* if ndim == 1:
* if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
* <size_t> src_stride == itemsize == <size_t> dst_stride):
* memcpy(dst_data, src_data, itemsize * dst_extent)
*/
goto __pyx_L4;
}
/* "View.MemoryView":1157
* memcpy(dst_data, src_data, itemsize * dst_extent)
* else:
* for i in range(dst_extent): # <<<<<<<<<<<<<<
* memcpy(dst_data, src_data, itemsize)
* src_data += src_stride
*/
/*else*/ {
__pyx_t_4 = __pyx_v_dst_extent;
__pyx_t_5 = __pyx_t_4;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1158
* else:
* for i in range(dst_extent):
* memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<<
* src_data += src_stride
* dst_data += dst_stride
*/
(void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
/* "View.MemoryView":1159
* for i in range(dst_extent):
* memcpy(dst_data, src_data, itemsize)
* src_data += src_stride # <<<<<<<<<<<<<<
* dst_data += dst_stride
* else:
*/
__pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
/* "View.MemoryView":1160
* memcpy(dst_data, src_data, itemsize)
* src_data += src_stride
* dst_data += dst_stride # <<<<<<<<<<<<<<
* else:
* for i in range(dst_extent):
*/
__pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
}
}
__pyx_L4:;
/* "View.MemoryView":1152
* cdef Py_ssize_t dst_stride = dst_strides[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* if (src_stride > 0 and dst_stride > 0 and
* <size_t> src_stride == itemsize == <size_t> dst_stride):
*/
goto __pyx_L3;
}
/* "View.MemoryView":1162
* dst_data += dst_stride
* else:
* for i in range(dst_extent): # <<<<<<<<<<<<<<
* _copy_strided_to_strided(src_data, src_strides + 1,
* dst_data, dst_strides + 1,
*/
/*else*/ {
__pyx_t_4 = __pyx_v_dst_extent;
__pyx_t_5 = __pyx_t_4;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1163
* else:
* for i in range(dst_extent):
* _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<<
* dst_data, dst_strides + 1,
* src_shape + 1, dst_shape + 1,
*/
_copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize);
/* "View.MemoryView":1167
* src_shape + 1, dst_shape + 1,
* ndim - 1, itemsize)
* src_data += src_stride # <<<<<<<<<<<<<<
* dst_data += dst_stride
*
*/
__pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
/* "View.MemoryView":1168
* ndim - 1, itemsize)
* src_data += src_stride
* dst_data += dst_stride # <<<<<<<<<<<<<<
*
* cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
*/
__pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
}
}
__pyx_L3:;
/* "View.MemoryView":1140
*
* @cython.cdivision(True)
* cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<<
* char *dst_data, Py_ssize_t *dst_strides,
* Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
*/
/* function exit code */
}
/* "View.MemoryView":1170
* dst_data += dst_stride
*
* cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* int ndim, size_t itemsize) nogil:
*/
static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
/* "View.MemoryView":1173
* __Pyx_memviewslice *dst,
* int ndim, size_t itemsize) nogil:
* _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<<
* src.shape, dst.shape, ndim, itemsize)
*
*/
_copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize);
/* "View.MemoryView":1170
* dst_data += dst_stride
*
* cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *dst,
* int ndim, size_t itemsize) nogil:
*/
/* function exit code */
}
/* "View.MemoryView":1177
*
* @cname('__pyx_memoryview_slice_get_size')
* cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<<
* "Return the size of the memory occupied by the slice in number of bytes"
* cdef Py_ssize_t shape, size = src.memview.view.itemsize
*/
static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
Py_ssize_t __pyx_v_shape;
Py_ssize_t __pyx_v_size;
Py_ssize_t __pyx_r;
Py_ssize_t __pyx_t_1;
Py_ssize_t *__pyx_t_2;
Py_ssize_t *__pyx_t_3;
Py_ssize_t *__pyx_t_4;
/* "View.MemoryView":1179
* cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:
* "Return the size of the memory occupied by the slice in number of bytes"
* cdef Py_ssize_t shape, size = src.memview.view.itemsize # <<<<<<<<<<<<<<
*
* for shape in src.shape[:ndim]:
*/
__pyx_t_1 = __pyx_v_src->memview->view.itemsize;
__pyx_v_size = __pyx_t_1;
/* "View.MemoryView":1181
* cdef Py_ssize_t shape, size = src.memview.view.itemsize
*
* for shape in src.shape[:ndim]: # <<<<<<<<<<<<<<
* size *= shape
*
*/
__pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim);
for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
__pyx_t_2 = __pyx_t_4;
__pyx_v_shape = (__pyx_t_2[0]);
/* "View.MemoryView":1182
*
* for shape in src.shape[:ndim]:
* size *= shape # <<<<<<<<<<<<<<
*
* return size
*/
__pyx_v_size = (__pyx_v_size * __pyx_v_shape);
}
/* "View.MemoryView":1184
* size *= shape
*
* return size # <<<<<<<<<<<<<<
*
* @cname('__pyx_fill_contig_strides_array')
*/
__pyx_r = __pyx_v_size;
goto __pyx_L0;
/* "View.MemoryView":1177
*
* @cname('__pyx_memoryview_slice_get_size')
* cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<<
* "Return the size of the memory occupied by the slice in number of bytes"
* cdef Py_ssize_t shape, size = src.memview.view.itemsize
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1187
*
* @cname('__pyx_fill_contig_strides_array')
* cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<<
* Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
* int ndim, char order) nogil:
*/
static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) {
int __pyx_v_idx;
Py_ssize_t __pyx_r;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
/* "View.MemoryView":1196
* cdef int idx
*
* if order == 'F': # <<<<<<<<<<<<<<
* for idx in range(ndim):
* strides[idx] = stride
*/
__pyx_t_1 = ((__pyx_v_order == 'F') != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1197
*
* if order == 'F':
* for idx in range(ndim): # <<<<<<<<<<<<<<
* strides[idx] = stride
* stride *= shape[idx]
*/
__pyx_t_2 = __pyx_v_ndim;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_idx = __pyx_t_4;
/* "View.MemoryView":1198
* if order == 'F':
* for idx in range(ndim):
* strides[idx] = stride # <<<<<<<<<<<<<<
* stride *= shape[idx]
* else:
*/
(__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
/* "View.MemoryView":1199
* for idx in range(ndim):
* strides[idx] = stride
* stride *= shape[idx] # <<<<<<<<<<<<<<
* else:
* for idx in range(ndim - 1, -1, -1):
*/
__pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
}
/* "View.MemoryView":1196
* cdef int idx
*
* if order == 'F': # <<<<<<<<<<<<<<
* for idx in range(ndim):
* strides[idx] = stride
*/
goto __pyx_L3;
}
/* "View.MemoryView":1201
* stride *= shape[idx]
* else:
* for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
* strides[idx] = stride
* stride *= shape[idx]
*/
/*else*/ {
for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
__pyx_v_idx = __pyx_t_2;
/* "View.MemoryView":1202
* else:
* for idx in range(ndim - 1, -1, -1):
* strides[idx] = stride # <<<<<<<<<<<<<<
* stride *= shape[idx]
*
*/
(__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
/* "View.MemoryView":1203
* for idx in range(ndim - 1, -1, -1):
* strides[idx] = stride
* stride *= shape[idx] # <<<<<<<<<<<<<<
*
* return stride
*/
__pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
}
}
__pyx_L3:;
/* "View.MemoryView":1205
* stride *= shape[idx]
*
* return stride # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_data_to_temp')
*/
__pyx_r = __pyx_v_stride;
goto __pyx_L0;
/* "View.MemoryView":1187
*
* @cname('__pyx_fill_contig_strides_array')
* cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<<
* Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
* int ndim, char order) nogil:
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1208
*
* @cname('__pyx_memoryview_copy_data_to_temp')
* cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *tmpslice,
* char order,
*/
static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) {
int __pyx_v_i;
void *__pyx_v_result;
size_t __pyx_v_itemsize;
size_t __pyx_v_size;
void *__pyx_r;
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
struct __pyx_memoryview_obj *__pyx_t_4;
int __pyx_t_5;
int __pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":1219
* cdef void *result
*
* cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<<
* cdef size_t size = slice_get_size(src, ndim)
*
*/
__pyx_t_1 = __pyx_v_src->memview->view.itemsize;
__pyx_v_itemsize = __pyx_t_1;
/* "View.MemoryView":1220
*
* cdef size_t itemsize = src.memview.view.itemsize
* cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<<
*
* result = malloc(size)
*/
__pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
/* "View.MemoryView":1222
* cdef size_t size = slice_get_size(src, ndim)
*
* result = malloc(size) # <<<<<<<<<<<<<<
* if not result:
* _err(MemoryError, NULL)
*/
__pyx_v_result = malloc(__pyx_v_size);
/* "View.MemoryView":1223
*
* result = malloc(size)
* if not result: # <<<<<<<<<<<<<<
* _err(MemoryError, NULL)
*
*/
__pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1224
* result = malloc(size)
* if not result:
* _err(MemoryError, NULL) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1224, __pyx_L1_error)
/* "View.MemoryView":1223
*
* result = malloc(size)
* if not result: # <<<<<<<<<<<<<<
* _err(MemoryError, NULL)
*
*/
}
/* "View.MemoryView":1227
*
*
* tmpslice.data = <char *> result # <<<<<<<<<<<<<<
* tmpslice.memview = src.memview
* for i in range(ndim):
*/
__pyx_v_tmpslice->data = ((char *)__pyx_v_result);
/* "View.MemoryView":1228
*
* tmpslice.data = <char *> result
* tmpslice.memview = src.memview # <<<<<<<<<<<<<<
* for i in range(ndim):
* tmpslice.shape[i] = src.shape[i]
*/
__pyx_t_4 = __pyx_v_src->memview;
__pyx_v_tmpslice->memview = __pyx_t_4;
/* "View.MemoryView":1229
* tmpslice.data = <char *> result
* tmpslice.memview = src.memview
* for i in range(ndim): # <<<<<<<<<<<<<<
* tmpslice.shape[i] = src.shape[i]
* tmpslice.suboffsets[i] = -1
*/
__pyx_t_3 = __pyx_v_ndim;
__pyx_t_5 = __pyx_t_3;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1230
* tmpslice.memview = src.memview
* for i in range(ndim):
* tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<<
* tmpslice.suboffsets[i] = -1
*
*/
(__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
/* "View.MemoryView":1231
* for i in range(ndim):
* tmpslice.shape[i] = src.shape[i]
* tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<<
*
* fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
*/
(__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
}
/* "View.MemoryView":1233
* tmpslice.suboffsets[i] = -1
*
* fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<<
* ndim, order)
*
*/
(void)(__pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order));
/* "View.MemoryView":1237
*
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if tmpslice.shape[i] == 1:
* tmpslice.strides[i] = 0
*/
__pyx_t_3 = __pyx_v_ndim;
__pyx_t_5 = __pyx_t_3;
for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
__pyx_v_i = __pyx_t_6;
/* "View.MemoryView":1238
*
* for i in range(ndim):
* if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<<
* tmpslice.strides[i] = 0
*
*/
__pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1239
* for i in range(ndim):
* if tmpslice.shape[i] == 1:
* tmpslice.strides[i] = 0 # <<<<<<<<<<<<<<
*
* if slice_is_contig(src[0], order, ndim):
*/
(__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
/* "View.MemoryView":1238
*
* for i in range(ndim):
* if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<<
* tmpslice.strides[i] = 0
*
*/
}
}
/* "View.MemoryView":1241
* tmpslice.strides[i] = 0
*
* if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<<
* memcpy(result, src.data, size)
* else:
*/
__pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1242
*
* if slice_is_contig(src[0], order, ndim):
* memcpy(result, src.data, size) # <<<<<<<<<<<<<<
* else:
* copy_strided_to_strided(src, tmpslice, ndim, itemsize)
*/
(void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
/* "View.MemoryView":1241
* tmpslice.strides[i] = 0
*
* if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<<
* memcpy(result, src.data, size)
* else:
*/
goto __pyx_L9;
}
/* "View.MemoryView":1244
* memcpy(result, src.data, size)
* else:
* copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<<
*
* return result
*/
/*else*/ {
copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
}
__pyx_L9:;
/* "View.MemoryView":1246
* copy_strided_to_strided(src, tmpslice, ndim, itemsize)
*
* return result # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_result;
goto __pyx_L0;
/* "View.MemoryView":1208
*
* @cname('__pyx_memoryview_copy_data_to_temp')
* cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice *tmpslice,
* char order,
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = NULL;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1251
*
* @cname('__pyx_memoryview_err_extents')
* cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<<
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" %
*/
static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err_extents", 0);
/* "View.MemoryView":1254
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" %
* (i, extent1, extent2)) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_err_dim')
*/
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1254, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1254, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1254, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1254, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_3 = 0;
/* "View.MemoryView":1253
* cdef int _err_extents(int i, Py_ssize_t extent1,
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<<
* (i, extent1, extent2))
*
*/
__pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1253, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1253, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_4, 0, 0, 0);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__PYX_ERR(1, 1253, __pyx_L1_error)
/* "View.MemoryView":1251
*
* @cname('__pyx_memoryview_err_extents')
* cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<<
* Py_ssize_t extent2) except -1 with gil:
* raise ValueError("got differing extents in dimension %d (got %d and %d)" %
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1257
*
* @cname('__pyx_memoryview_err_dim')
* cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii') % dim)
*
*/
static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err_dim", 0);
__Pyx_INCREF(__pyx_v_error);
/* "View.MemoryView":1258
* @cname('__pyx_memoryview_err_dim')
* cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
* raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_err')
*/
__pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1258, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1258, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1258, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_INCREF(__pyx_v_error);
__pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
if (likely(__pyx_t_2)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
__Pyx_INCREF(__pyx_t_2);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_3, function);
}
}
__pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1258, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_Raise(__pyx_t_1, 0, 0, 0);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__PYX_ERR(1, 1258, __pyx_L1_error)
/* "View.MemoryView":1257
*
* @cname('__pyx_memoryview_err_dim')
* cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii') % dim)
*
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_XDECREF(__pyx_v_error);
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1261
*
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<<
* if msg != NULL:
* raise error(msg.decode('ascii'))
*/
static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("_err", 0);
__Pyx_INCREF(__pyx_v_error);
/* "View.MemoryView":1262
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil:
* if msg != NULL: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii'))
* else:
*/
__pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
if (unlikely(__pyx_t_1)) {
/* "View.MemoryView":1263
* cdef int _err(object error, char *msg) except -1 with gil:
* if msg != NULL:
* raise error(msg.decode('ascii')) # <<<<<<<<<<<<<<
* else:
* raise error
*/
__pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1263, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_error);
__pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_4, function);
}
}
__pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1263, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__PYX_ERR(1, 1263, __pyx_L1_error)
/* "View.MemoryView":1262
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil:
* if msg != NULL: # <<<<<<<<<<<<<<
* raise error(msg.decode('ascii'))
* else:
*/
}
/* "View.MemoryView":1265
* raise error(msg.decode('ascii'))
* else:
* raise error # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_copy_contents')
*/
/*else*/ {
__Pyx_Raise(__pyx_v_error, 0, 0, 0);
__PYX_ERR(1, 1265, __pyx_L1_error)
}
/* "View.MemoryView":1261
*
* @cname('__pyx_memoryview_err')
* cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<<
* if msg != NULL:
* raise error(msg.decode('ascii'))
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__Pyx_XDECREF(__pyx_v_error);
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
return __pyx_r;
}
/* "View.MemoryView":1268
*
* @cname('__pyx_memoryview_copy_contents')
* cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice dst,
* int src_ndim, int dst_ndim,
*/
static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) {
void *__pyx_v_tmpdata;
size_t __pyx_v_itemsize;
int __pyx_v_i;
char __pyx_v_order;
int __pyx_v_broadcasting;
int __pyx_v_direct_copy;
__Pyx_memviewslice __pyx_v_tmp;
int __pyx_v_ndim;
int __pyx_r;
Py_ssize_t __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
int __pyx_t_6;
void *__pyx_t_7;
int __pyx_t_8;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* "View.MemoryView":1276
* Check for overlapping memory and verify the shapes.
* """
* cdef void *tmpdata = NULL # <<<<<<<<<<<<<<
* cdef size_t itemsize = src.memview.view.itemsize
* cdef int i
*/
__pyx_v_tmpdata = NULL;
/* "View.MemoryView":1277
* """
* cdef void *tmpdata = NULL
* cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<<
* cdef int i
* cdef char order = get_best_order(&src, src_ndim)
*/
__pyx_t_1 = __pyx_v_src.memview->view.itemsize;
__pyx_v_itemsize = __pyx_t_1;
/* "View.MemoryView":1279
* cdef size_t itemsize = src.memview.view.itemsize
* cdef int i
* cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<<
* cdef bint broadcasting = False
* cdef bint direct_copy = False
*/
__pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
/* "View.MemoryView":1280
* cdef int i
* cdef char order = get_best_order(&src, src_ndim)
* cdef bint broadcasting = False # <<<<<<<<<<<<<<
* cdef bint direct_copy = False
* cdef __Pyx_memviewslice tmp
*/
__pyx_v_broadcasting = 0;
/* "View.MemoryView":1281
* cdef char order = get_best_order(&src, src_ndim)
* cdef bint broadcasting = False
* cdef bint direct_copy = False # <<<<<<<<<<<<<<
* cdef __Pyx_memviewslice tmp
*
*/
__pyx_v_direct_copy = 0;
/* "View.MemoryView":1284
* cdef __Pyx_memviewslice tmp
*
* if src_ndim < dst_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim:
*/
__pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1285
*
* if src_ndim < dst_ndim:
* broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<<
* elif dst_ndim < src_ndim:
* broadcast_leading(&dst, dst_ndim, src_ndim)
*/
__pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
/* "View.MemoryView":1284
* cdef __Pyx_memviewslice tmp
*
* if src_ndim < dst_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim:
*/
goto __pyx_L3;
}
/* "View.MemoryView":1286
* if src_ndim < dst_ndim:
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&dst, dst_ndim, src_ndim)
*
*/
__pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1287
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim:
* broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<<
*
* cdef int ndim = max(src_ndim, dst_ndim)
*/
__pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
/* "View.MemoryView":1286
* if src_ndim < dst_ndim:
* broadcast_leading(&src, src_ndim, dst_ndim)
* elif dst_ndim < src_ndim: # <<<<<<<<<<<<<<
* broadcast_leading(&dst, dst_ndim, src_ndim)
*
*/
}
__pyx_L3:;
/* "View.MemoryView":1289
* broadcast_leading(&dst, dst_ndim, src_ndim)
*
* cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<<
*
* for i in range(ndim):
*/
__pyx_t_3 = __pyx_v_dst_ndim;
__pyx_t_4 = __pyx_v_src_ndim;
if (((__pyx_t_3 > __pyx_t_4) != 0)) {
__pyx_t_5 = __pyx_t_3;
} else {
__pyx_t_5 = __pyx_t_4;
}
__pyx_v_ndim = __pyx_t_5;
/* "View.MemoryView":1291
* cdef int ndim = max(src_ndim, dst_ndim)
*
* for i in range(ndim): # <<<<<<<<<<<<<<
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1:
*/
__pyx_t_5 = __pyx_v_ndim;
__pyx_t_3 = __pyx_t_5;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1292
*
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<<
* if src.shape[i] == 1:
* broadcasting = True
*/
__pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1293
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1: # <<<<<<<<<<<<<<
* broadcasting = True
* src.strides[i] = 0
*/
__pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1294
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1:
* broadcasting = True # <<<<<<<<<<<<<<
* src.strides[i] = 0
* else:
*/
__pyx_v_broadcasting = 1;
/* "View.MemoryView":1295
* if src.shape[i] == 1:
* broadcasting = True
* src.strides[i] = 0 # <<<<<<<<<<<<<<
* else:
* _err_extents(i, dst.shape[i], src.shape[i])
*/
(__pyx_v_src.strides[__pyx_v_i]) = 0;
/* "View.MemoryView":1293
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]:
* if src.shape[i] == 1: # <<<<<<<<<<<<<<
* broadcasting = True
* src.strides[i] = 0
*/
goto __pyx_L7;
}
/* "View.MemoryView":1297
* src.strides[i] = 0
* else:
* _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<<
*
* if src.suboffsets[i] >= 0:
*/
/*else*/ {
__pyx_t_6 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1297, __pyx_L1_error)
}
__pyx_L7:;
/* "View.MemoryView":1292
*
* for i in range(ndim):
* if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<<
* if src.shape[i] == 1:
* broadcasting = True
*/
}
/* "View.MemoryView":1299
* _err_extents(i, dst.shape[i], src.shape[i])
*
* if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
*/
__pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1300
*
* if src.suboffsets[i] >= 0:
* _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<<
*
* if slices_overlap(&src, &dst, ndim, itemsize):
*/
__pyx_t_6 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1300, __pyx_L1_error)
/* "View.MemoryView":1299
* _err_extents(i, dst.shape[i], src.shape[i])
*
* if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<<
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
*/
}
}
/* "View.MemoryView":1302
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
* if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<<
*
* if not slice_is_contig(src, order, ndim):
*/
__pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1304
* if slices_overlap(&src, &dst, ndim, itemsize):
*
* if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<<
* order = get_best_order(&dst, ndim)
*
*/
__pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1305
*
* if not slice_is_contig(src, order, ndim):
* order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<<
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
*/
__pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
/* "View.MemoryView":1304
* if slices_overlap(&src, &dst, ndim, itemsize):
*
* if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<<
* order = get_best_order(&dst, ndim)
*
*/
}
/* "View.MemoryView":1307
* order = get_best_order(&dst, ndim)
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<<
* src = tmp
*
*/
__pyx_t_7 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_7 == ((void *)NULL))) __PYX_ERR(1, 1307, __pyx_L1_error)
__pyx_v_tmpdata = __pyx_t_7;
/* "View.MemoryView":1308
*
* tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
* src = tmp # <<<<<<<<<<<<<<
*
* if not broadcasting:
*/
__pyx_v_src = __pyx_v_tmp;
/* "View.MemoryView":1302
* _err_dim(ValueError, "Dimension %d is not direct", i)
*
* if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<<
*
* if not slice_is_contig(src, order, ndim):
*/
}
/* "View.MemoryView":1310
* src = tmp
*
* if not broadcasting: # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1313
*
*
* if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(dst, 'C', ndim)
* elif slice_is_contig(src, 'F', ndim):
*/
__pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1314
*
* if slice_is_contig(src, 'C', ndim):
* direct_copy = slice_is_contig(dst, 'C', ndim) # <<<<<<<<<<<<<<
* elif slice_is_contig(src, 'F', ndim):
* direct_copy = slice_is_contig(dst, 'F', ndim)
*/
__pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);
/* "View.MemoryView":1313
*
*
* if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(dst, 'C', ndim)
* elif slice_is_contig(src, 'F', ndim):
*/
goto __pyx_L12;
}
/* "View.MemoryView":1315
* if slice_is_contig(src, 'C', ndim):
* direct_copy = slice_is_contig(dst, 'C', ndim)
* elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(dst, 'F', ndim)
*
*/
__pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1316
* direct_copy = slice_is_contig(dst, 'C', ndim)
* elif slice_is_contig(src, 'F', ndim):
* direct_copy = slice_is_contig(dst, 'F', ndim) # <<<<<<<<<<<<<<
*
* if direct_copy:
*/
__pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);
/* "View.MemoryView":1315
* if slice_is_contig(src, 'C', ndim):
* direct_copy = slice_is_contig(dst, 'C', ndim)
* elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<<
* direct_copy = slice_is_contig(dst, 'F', ndim)
*
*/
}
__pyx_L12:;
/* "View.MemoryView":1318
* direct_copy = slice_is_contig(dst, 'F', ndim)
*
* if direct_copy: # <<<<<<<<<<<<<<
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
*/
__pyx_t_2 = (__pyx_v_direct_copy != 0);
if (__pyx_t_2) {
/* "View.MemoryView":1320
* if direct_copy:
*
* refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
* memcpy(dst.data, src.data, slice_get_size(&src, ndim))
* refcount_copying(&dst, dtype_is_object, ndim, True)
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
/* "View.MemoryView":1321
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
* memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<<
* refcount_copying(&dst, dtype_is_object, ndim, True)
* free(tmpdata)
*/
(void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
/* "View.MemoryView":1322
* refcount_copying(&dst, dtype_is_object, ndim, False)
* memcpy(dst.data, src.data, slice_get_size(&src, ndim))
* refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
* free(tmpdata)
* return 0
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
/* "View.MemoryView":1323
* memcpy(dst.data, src.data, slice_get_size(&src, ndim))
* refcount_copying(&dst, dtype_is_object, ndim, True)
* free(tmpdata) # <<<<<<<<<<<<<<
* return 0
*
*/
free(__pyx_v_tmpdata);
/* "View.MemoryView":1324
* refcount_copying(&dst, dtype_is_object, ndim, True)
* free(tmpdata)
* return 0 # <<<<<<<<<<<<<<
*
* if order == 'F' == get_best_order(&dst, ndim):
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":1318
* direct_copy = slice_is_contig(dst, 'F', ndim)
*
* if direct_copy: # <<<<<<<<<<<<<<
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
*/
}
/* "View.MemoryView":1310
* src = tmp
*
* if not broadcasting: # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":1326
* return 0
*
* if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = (__pyx_v_order == 'F');
if (__pyx_t_2) {
__pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
}
__pyx_t_8 = (__pyx_t_2 != 0);
if (__pyx_t_8) {
/* "View.MemoryView":1329
*
*
* transpose_memslice(&src) # <<<<<<<<<<<<<<
* transpose_memslice(&dst)
*
*/
__pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1329, __pyx_L1_error)
/* "View.MemoryView":1330
*
* transpose_memslice(&src)
* transpose_memslice(&dst) # <<<<<<<<<<<<<<
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
*/
__pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1330, __pyx_L1_error)
/* "View.MemoryView":1326
* return 0
*
* if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<<
*
*
*/
}
/* "View.MemoryView":1332
* transpose_memslice(&dst)
*
* refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
* copy_strided_to_strided(&src, &dst, ndim, itemsize)
* refcount_copying(&dst, dtype_is_object, ndim, True)
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
/* "View.MemoryView":1333
*
* refcount_copying(&dst, dtype_is_object, ndim, False)
* copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<<
* refcount_copying(&dst, dtype_is_object, ndim, True)
*
*/
copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
/* "View.MemoryView":1334
* refcount_copying(&dst, dtype_is_object, ndim, False)
* copy_strided_to_strided(&src, &dst, ndim, itemsize)
* refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
*
* free(tmpdata)
*/
__pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
/* "View.MemoryView":1336
* refcount_copying(&dst, dtype_is_object, ndim, True)
*
* free(tmpdata) # <<<<<<<<<<<<<<
* return 0
*
*/
free(__pyx_v_tmpdata);
/* "View.MemoryView":1337
*
* free(tmpdata)
* return 0 # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_broadcast_leading')
*/
__pyx_r = 0;
goto __pyx_L0;
/* "View.MemoryView":1268
*
* @cname('__pyx_memoryview_copy_contents')
* cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<<
* __Pyx_memviewslice dst,
* int src_ndim, int dst_ndim,
*/
/* function exit code */
__pyx_L1_error:;
{
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
__pyx_r = -1;
__pyx_L0:;
return __pyx_r;
}
/* "View.MemoryView":1340
*
* @cname('__pyx_memoryview_broadcast_leading')
* cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<<
* int ndim,
* int ndim_other) nogil:
*/
static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
int __pyx_v_i;
int __pyx_v_offset;
int __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
/* "View.MemoryView":1344
* int ndim_other) nogil:
* cdef int i
* cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<<
*
* for i in range(ndim - 1, -1, -1):
*/
__pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
/* "View.MemoryView":1346
* cdef int offset = ndim_other - ndim
*
* for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
* mslice.shape[i + offset] = mslice.shape[i]
* mslice.strides[i + offset] = mslice.strides[i]
*/
for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "View.MemoryView":1347
*
* for i in range(ndim - 1, -1, -1):
* mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<<
* mslice.strides[i + offset] = mslice.strides[i]
* mslice.suboffsets[i + offset] = mslice.suboffsets[i]
*/
(__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
/* "View.MemoryView":1348
* for i in range(ndim - 1, -1, -1):
* mslice.shape[i + offset] = mslice.shape[i]
* mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<<
* mslice.suboffsets[i + offset] = mslice.suboffsets[i]
*
*/
(__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
/* "View.MemoryView":1349
* mslice.shape[i + offset] = mslice.shape[i]
* mslice.strides[i + offset] = mslice.strides[i]
* mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<<
*
* for i in range(offset):
*/
(__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
}
/* "View.MemoryView":1351
* mslice.suboffsets[i + offset] = mslice.suboffsets[i]
*
* for i in range(offset): # <<<<<<<<<<<<<<
* mslice.shape[i] = 1
* mslice.strides[i] = mslice.strides[0]
*/
__pyx_t_1 = __pyx_v_offset;
__pyx_t_2 = __pyx_t_1;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1352
*
* for i in range(offset):
* mslice.shape[i] = 1 # <<<<<<<<<<<<<<
* mslice.strides[i] = mslice.strides[0]
* mslice.suboffsets[i] = -1
*/
(__pyx_v_mslice->shape[__pyx_v_i]) = 1;
/* "View.MemoryView":1353
* for i in range(offset):
* mslice.shape[i] = 1
* mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<<
* mslice.suboffsets[i] = -1
*
*/
(__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
/* "View.MemoryView":1354
* mslice.shape[i] = 1
* mslice.strides[i] = mslice.strides[0]
* mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<<
*
*
*/
(__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
}
/* "View.MemoryView":1340
*
* @cname('__pyx_memoryview_broadcast_leading')
* cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<<
* int ndim,
* int ndim_other) nogil:
*/
/* function exit code */
}
/* "View.MemoryView":1362
*
* @cname('__pyx_memoryview_refcount_copying')
* cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<<
* int ndim, bint inc) nogil:
*
*/
static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) {
int __pyx_t_1;
/* "View.MemoryView":1366
*
*
* if dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice_with_gil(dst.data, dst.shape,
* dst.strides, ndim, inc)
*/
__pyx_t_1 = (__pyx_v_dtype_is_object != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1367
*
* if dtype_is_object:
* refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<<
* dst.strides, ndim, inc)
*
*/
__pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc);
/* "View.MemoryView":1366
*
*
* if dtype_is_object: # <<<<<<<<<<<<<<
* refcount_objects_in_slice_with_gil(dst.data, dst.shape,
* dst.strides, ndim, inc)
*/
}
/* "View.MemoryView":1362
*
* @cname('__pyx_memoryview_refcount_copying')
* cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<<
* int ndim, bint inc) nogil:
*
*/
/* function exit code */
}
/* "View.MemoryView":1371
*
* @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
* cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* bint inc) with gil:
*/
static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
__Pyx_RefNannyDeclarations
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
#endif
__Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
/* "View.MemoryView":1374
* Py_ssize_t *strides, int ndim,
* bint inc) with gil:
* refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<<
*
* @cname('__pyx_memoryview_refcount_objects_in_slice')
*/
__pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
/* "View.MemoryView":1371
*
* @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
* cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* bint inc) with gil:
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
#ifdef WITH_THREAD
__Pyx_PyGILState_Release(__pyx_gilstate_save);
#endif
}
/* "View.MemoryView":1377
*
* @cname('__pyx_memoryview_refcount_objects_in_slice')
* cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim, bint inc):
* cdef Py_ssize_t i
*/
static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
CYTHON_UNUSED Py_ssize_t __pyx_v_i;
__Pyx_RefNannyDeclarations
Py_ssize_t __pyx_t_1;
Py_ssize_t __pyx_t_2;
Py_ssize_t __pyx_t_3;
int __pyx_t_4;
__Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
/* "View.MemoryView":1381
* cdef Py_ssize_t i
*
* for i in range(shape[0]): # <<<<<<<<<<<<<<
* if ndim == 1:
* if inc:
*/
__pyx_t_1 = (__pyx_v_shape[0]);
__pyx_t_2 = __pyx_t_1;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "View.MemoryView":1382
*
* for i in range(shape[0]):
* if ndim == 1: # <<<<<<<<<<<<<<
* if inc:
* Py_INCREF((<PyObject **> data)[0])
*/
__pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
if (__pyx_t_4) {
/* "View.MemoryView":1383
* for i in range(shape[0]):
* if ndim == 1:
* if inc: # <<<<<<<<<<<<<<
* Py_INCREF((<PyObject **> data)[0])
* else:
*/
__pyx_t_4 = (__pyx_v_inc != 0);
if (__pyx_t_4) {
/* "View.MemoryView":1384
* if ndim == 1:
* if inc:
* Py_INCREF((<PyObject **> data)[0]) # <<<<<<<<<<<<<<
* else:
* Py_DECREF((<PyObject **> data)[0])
*/
Py_INCREF((((PyObject **)__pyx_v_data)[0]));
/* "View.MemoryView":1383
* for i in range(shape[0]):
* if ndim == 1:
* if inc: # <<<<<<<<<<<<<<
* Py_INCREF((<PyObject **> data)[0])
* else:
*/
goto __pyx_L6;
}
/* "View.MemoryView":1386
* Py_INCREF((<PyObject **> data)[0])
* else:
* Py_DECREF((<PyObject **> data)[0]) # <<<<<<<<<<<<<<
* else:
* refcount_objects_in_slice(data, shape + 1, strides + 1,
*/
/*else*/ {
Py_DECREF((((PyObject **)__pyx_v_data)[0]));
}
__pyx_L6:;
/* "View.MemoryView":1382
*
* for i in range(shape[0]):
* if ndim == 1: # <<<<<<<<<<<<<<
* if inc:
* Py_INCREF((<PyObject **> data)[0])
*/
goto __pyx_L5;
}
/* "View.MemoryView":1388
* Py_DECREF((<PyObject **> data)[0])
* else:
* refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<<
* ndim - 1, inc)
*
*/
/*else*/ {
/* "View.MemoryView":1389
* else:
* refcount_objects_in_slice(data, shape + 1, strides + 1,
* ndim - 1, inc) # <<<<<<<<<<<<<<
*
* data += strides[0]
*/
__pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
}
__pyx_L5:;
/* "View.MemoryView":1391
* ndim - 1, inc)
*
* data += strides[0] # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
}
/* "View.MemoryView":1377
*
* @cname('__pyx_memoryview_refcount_objects_in_slice')
* cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim, bint inc):
* cdef Py_ssize_t i
*/
/* function exit code */
__Pyx_RefNannyFinishContext();
}
/* "View.MemoryView":1397
*
* @cname('__pyx_memoryview_slice_assign_scalar')
* cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<<
* size_t itemsize, void *item,
* bint dtype_is_object) nogil:
*/
static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) {
/* "View.MemoryView":1400
* size_t itemsize, void *item,
* bint dtype_is_object) nogil:
* refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
* _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
* itemsize, item)
*/
__pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
/* "View.MemoryView":1401
* bint dtype_is_object) nogil:
* refcount_copying(dst, dtype_is_object, ndim, False)
* _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<<
* itemsize, item)
* refcount_copying(dst, dtype_is_object, ndim, True)
*/
__pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item);
/* "View.MemoryView":1403
* _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
* itemsize, item)
* refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
*
*
*/
__pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
/* "View.MemoryView":1397
*
* @cname('__pyx_memoryview_slice_assign_scalar')
* cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<<
* size_t itemsize, void *item,
* bint dtype_is_object) nogil:
*/
/* function exit code */
}
/* "View.MemoryView":1407
*
* @cname('__pyx_memoryview__slice_assign_scalar')
* cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* size_t itemsize, void *item) nogil:
*/
static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) {
CYTHON_UNUSED Py_ssize_t __pyx_v_i;
Py_ssize_t __pyx_v_stride;
Py_ssize_t __pyx_v_extent;
int __pyx_t_1;
Py_ssize_t __pyx_t_2;
Py_ssize_t __pyx_t_3;
Py_ssize_t __pyx_t_4;
/* "View.MemoryView":1411
* size_t itemsize, void *item) nogil:
* cdef Py_ssize_t i
* cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<<
* cdef Py_ssize_t extent = shape[0]
*
*/
__pyx_v_stride = (__pyx_v_strides[0]);
/* "View.MemoryView":1412
* cdef Py_ssize_t i
* cdef Py_ssize_t stride = strides[0]
* cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<<
*
* if ndim == 1:
*/
__pyx_v_extent = (__pyx_v_shape[0]);
/* "View.MemoryView":1414
* cdef Py_ssize_t extent = shape[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* for i in range(extent):
* memcpy(data, item, itemsize)
*/
__pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
if (__pyx_t_1) {
/* "View.MemoryView":1415
*
* if ndim == 1:
* for i in range(extent): # <<<<<<<<<<<<<<
* memcpy(data, item, itemsize)
* data += stride
*/
__pyx_t_2 = __pyx_v_extent;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1416
* if ndim == 1:
* for i in range(extent):
* memcpy(data, item, itemsize) # <<<<<<<<<<<<<<
* data += stride
* else:
*/
(void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
/* "View.MemoryView":1417
* for i in range(extent):
* memcpy(data, item, itemsize)
* data += stride # <<<<<<<<<<<<<<
* else:
* for i in range(extent):
*/
__pyx_v_data = (__pyx_v_data + __pyx_v_stride);
}
/* "View.MemoryView":1414
* cdef Py_ssize_t extent = shape[0]
*
* if ndim == 1: # <<<<<<<<<<<<<<
* for i in range(extent):
* memcpy(data, item, itemsize)
*/
goto __pyx_L3;
}
/* "View.MemoryView":1419
* data += stride
* else:
* for i in range(extent): # <<<<<<<<<<<<<<
* _slice_assign_scalar(data, shape + 1, strides + 1,
* ndim - 1, itemsize, item)
*/
/*else*/ {
__pyx_t_2 = __pyx_v_extent;
__pyx_t_3 = __pyx_t_2;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_i = __pyx_t_4;
/* "View.MemoryView":1420
* else:
* for i in range(extent):
* _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<<
* ndim - 1, itemsize, item)
* data += stride
*/
__pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item);
/* "View.MemoryView":1422
* _slice_assign_scalar(data, shape + 1, strides + 1,
* ndim - 1, itemsize, item)
* data += stride # <<<<<<<<<<<<<<
*
*
*/
__pyx_v_data = (__pyx_v_data + __pyx_v_stride);
}
}
__pyx_L3:;
/* "View.MemoryView":1407
*
* @cname('__pyx_memoryview__slice_assign_scalar')
* cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
* Py_ssize_t *strides, int ndim,
* size_t itemsize, void *item) nogil:
*/
/* function exit code */
}
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_result
*/
/* Python wrapper */
static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v___pyx_type = 0;
long __pyx_v___pyx_checksum;
PyObject *__pyx_v___pyx_state = 0;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
PyObject* values[3] = {0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
}
__pyx_v___pyx_type = values[0];
__pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
__pyx_v___pyx_state = values[2];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_v___pyx_PickleError = 0;
PyObject *__pyx_v___pyx_result = 0;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
int __pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
/* "(tree fragment)":4
* cdef object __pyx_PickleError
* cdef object __pyx_result
* if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<<
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
*/
__pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
if (__pyx_t_1) {
/* "(tree fragment)":5
* cdef object __pyx_result
* if __pyx_checksum != 0xb068931:
* from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type)
*/
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_n_s_PickleError);
__Pyx_GIVEREF(__pyx_n_s_PickleError);
PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
__pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_t_2);
__pyx_v___pyx_PickleError = __pyx_t_2;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "(tree fragment)":6
* if __pyx_checksum != 0xb068931:
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) # <<<<<<<<<<<<<<
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None:
*/
__pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_INCREF(__pyx_v___pyx_PickleError);
__pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
}
}
__pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__PYX_ERR(1, 6, __pyx_L1_error)
/* "(tree fragment)":4
* cdef object __pyx_PickleError
* cdef object __pyx_result
* if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<<
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
*/
}
/* "(tree fragment)":7
* from pickle import PickleError as __pyx_PickleError
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type) # <<<<<<<<<<<<<<
* if __pyx_state is not None:
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
*/
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
}
}
__pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v___pyx_result = __pyx_t_3;
__pyx_t_3 = 0;
/* "(tree fragment)":8
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None: # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
*/
__pyx_t_1 = (__pyx_v___pyx_state != Py_None);
__pyx_t_6 = (__pyx_t_1 != 0);
if (__pyx_t_6) {
/* "(tree fragment)":9
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None:
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
*/
if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
__pyx_t_3 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "(tree fragment)":8
* raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
* __pyx_result = Enum.__new__(__pyx_type)
* if __pyx_state is not None: # <<<<<<<<<<<<<<
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
*/
}
/* "(tree fragment)":10
* if __pyx_state is not None:
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result # <<<<<<<<<<<<<<
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0]
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v___pyx_result);
__pyx_r = __pyx_v___pyx_result;
goto __pyx_L0;
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_result
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v___pyx_PickleError);
__Pyx_XDECREF(__pyx_v___pyx_result);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "(tree fragment)":11
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
*/
static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
int __pyx_t_2;
Py_ssize_t __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
/* "(tree fragment)":12
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0] # <<<<<<<<<<<<<<
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
* __pyx_result.__dict__.update(__pyx_state[1])
*/
if (unlikely(__pyx_v___pyx_state == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 12, __pyx_L1_error)
}
__pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_v___pyx_result->name);
__Pyx_DECREF(__pyx_v___pyx_result->name);
__pyx_v___pyx_result->name = __pyx_t_1;
__pyx_t_1 = 0;
/* "(tree fragment)":13
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
* __pyx_result.__dict__.update(__pyx_state[1])
*/
if (unlikely(__pyx_v___pyx_state == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(1, 13, __pyx_L1_error)
}
__pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
__pyx_t_4 = ((__pyx_t_3 > 1) != 0);
if (__pyx_t_4) {
} else {
__pyx_t_2 = __pyx_t_4;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
__pyx_t_5 = (__pyx_t_4 != 0);
__pyx_t_2 = __pyx_t_5;
__pyx_L4_bool_binop_done:;
if (__pyx_t_2) {
/* "(tree fragment)":14
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
* __pyx_result.__dict__.update(__pyx_state[1]) # <<<<<<<<<<<<<<
*/
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(__pyx_v___pyx_state == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 14, __pyx_L1_error)
}
__pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_8 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
__pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
if (likely(__pyx_t_8)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
__Pyx_INCREF(__pyx_t_8);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_7, function);
}
}
__pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
__Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "(tree fragment)":13
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
* __pyx_result.__dict__.update(__pyx_state[1])
*/
}
/* "(tree fragment)":11
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static struct __pyx_vtabstruct_array __pyx_vtable_array;
static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
struct __pyx_array_obj *p;
PyObject *o;
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
o = (*t->tp_alloc)(t, 0);
} else {
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
}
if (unlikely(!o)) return 0;
p = ((struct __pyx_array_obj *)o);
p->__pyx_vtab = __pyx_vtabptr_array;
p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
return o;
bad:
Py_DECREF(o); o = 0;
return NULL;
}
static void __pyx_tp_dealloc_array(PyObject *o) {
struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
#if CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
__pyx_array___dealloc__(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
Py_CLEAR(p->mode);
Py_CLEAR(p->_format);
(*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
PyObject *r;
PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
Py_DECREF(x);
return r;
}
static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
return __pyx_array___setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
"Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
return -1;
}
}
static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Clear();
v = __pyx_array___getattr__(o, n);
}
return v;
}
static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
}
static PyMethodDef __pyx_methods_array[] = {
{"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets_array[] = {
{(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
{0, 0, 0, 0, 0}
};
static PySequenceMethods __pyx_tp_as_sequence_array = {
__pyx_array___len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
__pyx_sq_item_array, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
0, /*sq_contains*/
0, /*sq_inplace_concat*/
0, /*sq_inplace_repeat*/
};
static PyMappingMethods __pyx_tp_as_mapping_array = {
__pyx_array___len__, /*mp_length*/
__pyx_array___getitem__, /*mp_subscript*/
__pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
};
static PyBufferProcs __pyx_tp_as_buffer_array = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getwritebuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getsegcount*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getcharbuffer*/
#endif
__pyx_array_getbuffer, /*bf_getbuffer*/
0, /*bf_releasebuffer*/
};
static PyTypeObject __pyx_type___pyx_array = {
PyVarObject_HEAD_INIT(0, 0)
"pyapprox.cython.adaptive_sparse_grid.array", /*tp_name*/
sizeof(struct __pyx_array_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_array, /*tp_dealloc*/
#if PY_VERSION_HEX < 0x030800b4
0, /*tp_print*/
#endif
#if PY_VERSION_HEX >= 0x030800b4
0, /*tp_vectorcall_offset*/
#endif
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
0, /*tp_repr*/
0, /*tp_as_number*/
&__pyx_tp_as_sequence_array, /*tp_as_sequence*/
&__pyx_tp_as_mapping_array, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
__pyx_tp_getattro_array, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_array, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
0, /*tp_doc*/
0, /*tp_traverse*/
0, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_array, /*tp_methods*/
0, /*tp_members*/
__pyx_getsets_array, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_array, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
};
static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
struct __pyx_MemviewEnum_obj *p;
PyObject *o;
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
o = (*t->tp_alloc)(t, 0);
} else {
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
}
if (unlikely(!o)) return 0;
p = ((struct __pyx_MemviewEnum_obj *)o);
p->name = Py_None; Py_INCREF(Py_None);
return o;
}
static void __pyx_tp_dealloc_Enum(PyObject *o) {
struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
#if CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
PyObject_GC_UnTrack(o);
Py_CLEAR(p->name);
(*Py_TYPE(o)->tp_free)(o);
}
static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
int e;
struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
if (p->name) {
e = (*v)(p->name, a); if (e) return e;
}
return 0;
}
static int __pyx_tp_clear_Enum(PyObject *o) {
PyObject* tmp;
struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
tmp = ((PyObject*)p->name);
p->name = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
return 0;
}
static PyMethodDef __pyx_methods_Enum[] = {
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static PyTypeObject __pyx_type___pyx_MemviewEnum = {
PyVarObject_HEAD_INIT(0, 0)
"pyapprox.cython.adaptive_sparse_grid.Enum", /*tp_name*/
sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_Enum, /*tp_dealloc*/
#if PY_VERSION_HEX < 0x030800b4
0, /*tp_print*/
#endif
#if PY_VERSION_HEX >= 0x030800b4
0, /*tp_vectorcall_offset*/
#endif
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
__pyx_MemviewEnum___repr__, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
0, /*tp_doc*/
__pyx_tp_traverse_Enum, /*tp_traverse*/
__pyx_tp_clear_Enum, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_Enum, /*tp_methods*/
0, /*tp_members*/
0, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
__pyx_MemviewEnum___init__, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_Enum, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
};
static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
struct __pyx_memoryview_obj *p;
PyObject *o;
if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
o = (*t->tp_alloc)(t, 0);
} else {
o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
}
if (unlikely(!o)) return 0;
p = ((struct __pyx_memoryview_obj *)o);
p->__pyx_vtab = __pyx_vtabptr_memoryview;
p->obj = Py_None; Py_INCREF(Py_None);
p->_size = Py_None; Py_INCREF(Py_None);
p->_array_interface = Py_None; Py_INCREF(Py_None);
p->view.obj = NULL;
if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
return o;
bad:
Py_DECREF(o); o = 0;
return NULL;
}
static void __pyx_tp_dealloc_memoryview(PyObject *o) {
struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
#if CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
PyObject_GC_UnTrack(o);
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
__pyx_memoryview___dealloc__(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
Py_CLEAR(p->obj);
Py_CLEAR(p->_size);
Py_CLEAR(p->_array_interface);
(*Py_TYPE(o)->tp_free)(o);
}
static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
int e;
struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
if (p->obj) {
e = (*v)(p->obj, a); if (e) return e;
}
if (p->_size) {
e = (*v)(p->_size, a); if (e) return e;
}
if (p->_array_interface) {
e = (*v)(p->_array_interface, a); if (e) return e;
}
if (p->view.obj) {
e = (*v)(p->view.obj, a); if (e) return e;
}
return 0;
}
static int __pyx_tp_clear_memoryview(PyObject *o) {
PyObject* tmp;
struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
tmp = ((PyObject*)p->obj);
p->obj = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
tmp = ((PyObject*)p->_size);
p->_size = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
tmp = ((PyObject*)p->_array_interface);
p->_array_interface = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
Py_CLEAR(p->view.obj);
return 0;
}
static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
PyObject *r;
PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
Py_DECREF(x);
return r;
}
static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
return __pyx_memoryview___setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
"Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
return -1;
}
}
static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
}
static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
}
static PyMethodDef __pyx_methods_memoryview[] = {
{"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
{"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
{"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
{"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets_memoryview[] = {
{(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
{(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
{(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
{(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
{(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
{(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
{(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
{(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
{(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
{0, 0, 0, 0, 0}
};
static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
__pyx_memoryview___len__, /*sq_length*/
0, /*sq_concat*/
0, /*sq_repeat*/
__pyx_sq_item_memoryview, /*sq_item*/
0, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
0, /*sq_contains*/
0, /*sq_inplace_concat*/
0, /*sq_inplace_repeat*/
};
static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
__pyx_memoryview___len__, /*mp_length*/
__pyx_memoryview___getitem__, /*mp_subscript*/
__pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
};
static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
#if PY_MAJOR_VERSION < 3
0, /*bf_getreadbuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getwritebuffer*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getsegcount*/
#endif
#if PY_MAJOR_VERSION < 3
0, /*bf_getcharbuffer*/
#endif
__pyx_memoryview_getbuffer, /*bf_getbuffer*/
0, /*bf_releasebuffer*/
};
static PyTypeObject __pyx_type___pyx_memoryview = {
PyVarObject_HEAD_INIT(0, 0)
"pyapprox.cython.adaptive_sparse_grid.memoryview", /*tp_name*/
sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc_memoryview, /*tp_dealloc*/
#if PY_VERSION_HEX < 0x030800b4
0, /*tp_print*/
#endif
#if PY_VERSION_HEX >= 0x030800b4
0, /*tp_vectorcall_offset*/
#endif
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
__pyx_memoryview___repr__, /*tp_repr*/
0, /*tp_as_number*/
&__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
&__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
__pyx_memoryview___str__, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
&__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
0, /*tp_doc*/
__pyx_tp_traverse_memoryview, /*tp_traverse*/
__pyx_tp_clear_memoryview, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods_memoryview, /*tp_methods*/
0, /*tp_members*/
__pyx_getsets_memoryview, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new_memoryview, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
};
static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
struct __pyx_memoryviewslice_obj *p;
PyObject *o = __pyx_tp_new_memoryview(t, a, k);
if (unlikely(!o)) return 0;
p = ((struct __pyx_memoryviewslice_obj *)o);
p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
p->from_object = Py_None; Py_INCREF(Py_None);
p->from_slice.memview = NULL;
return o;
}
static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
#if CYTHON_USE_TP_FINALIZE
if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
if (PyObject_CallFinalizerFromDealloc(o)) return;
}
#endif
PyObject_GC_UnTrack(o);
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
++Py_REFCNT(o);
__pyx_memoryviewslice___dealloc__(o);
--Py_REFCNT(o);
PyErr_Restore(etype, eval, etb);
}
Py_CLEAR(p->from_object);
PyObject_GC_Track(o);
__pyx_tp_dealloc_memoryview(o);
}
static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
int e;
struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
if (p->from_object) {
e = (*v)(p->from_object, a); if (e) return e;
}
return 0;
}
static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
PyObject* tmp;
struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
__pyx_tp_clear_memoryview(o);
tmp = ((PyObject*)p->from_object);
p->from_object = Py_None; Py_INCREF(Py_None);
Py_XDECREF(tmp);
__PYX_XDEC_MEMVIEW(&p->from_slice, 1);
return 0;
}
static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
}
static PyMethodDef __pyx_methods__memoryviewslice[] = {
{"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
{0, 0, 0, 0}
};
static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
{(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
{0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_type___pyx_memoryviewslice = {
PyVarObject_HEAD_INIT(0, 0)
"pyapprox.cython.adaptive_sparse_grid._memoryviewslice", /*tp_name*/
sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
0, /*tp_itemsize*/
__pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
#if PY_VERSION_HEX < 0x030800b4
0, /*tp_print*/
#endif
#if PY_VERSION_HEX >= 0x030800b4
0, /*tp_vectorcall_offset*/
#endif
0, /*tp_getattr*/
0, /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
0, /*tp_compare*/
#endif
#if PY_MAJOR_VERSION >= 3
0, /*tp_as_async*/
#endif
#if CYTHON_COMPILING_IN_PYPY
__pyx_memoryview___repr__, /*tp_repr*/
#else
0, /*tp_repr*/
#endif
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
#if CYTHON_COMPILING_IN_PYPY
__pyx_memoryview___str__, /*tp_str*/
#else
0, /*tp_str*/
#endif
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
"Internal class for passing memoryview slices to Python", /*tp_doc*/
__pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
__pyx_tp_clear__memoryviewslice, /*tp_clear*/
0, /*tp_richcompare*/
0, /*tp_weaklistoffset*/
0, /*tp_iter*/
0, /*tp_iternext*/
__pyx_methods__memoryviewslice, /*tp_methods*/
0, /*tp_members*/
__pyx_getsets__memoryviewslice, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
0, /*tp_descr_get*/
0, /*tp_descr_set*/
0, /*tp_dictoffset*/
0, /*tp_init*/
0, /*tp_alloc*/
__pyx_tp_new__memoryviewslice, /*tp_new*/
0, /*tp_free*/
0, /*tp_is_gc*/
0, /*tp_bases*/
0, /*tp_mro*/
0, /*tp_cache*/
0, /*tp_subclasses*/
0, /*tp_weaklist*/
0, /*tp_del*/
0, /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
0, /*tp_finalize*/
#endif
#if PY_VERSION_HEX >= 0x030800b1
0, /*tp_vectorcall*/
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0, /*tp_print*/
#endif
};
static PyMethodDef __pyx_methods[] = {
{0, 0, 0, 0}
};
#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_adaptive_sparse_grid(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
{Py_mod_create, (void*)__pyx_pymod_create},
{Py_mod_exec, (void*)__pyx_pymod_exec_adaptive_sparse_grid},
{0, NULL}
};
#endif
static struct PyModuleDef __pyx_moduledef = {
PyModuleDef_HEAD_INIT,
"adaptive_sparse_grid",
0, /* m_doc */
#if CYTHON_PEP489_MULTI_PHASE_INIT
0, /* m_size */
#else
-1, /* m_size */
#endif
__pyx_methods /* m_methods */,
#if CYTHON_PEP489_MULTI_PHASE_INIT
__pyx_moduledef_slots, /* m_slots */
#else
NULL, /* m_reload */
#endif
NULL, /* m_traverse */
NULL, /* m_clear */
NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
#define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#define CYTHON_SMALL_CODE __attribute__((cold))
#else
#define CYTHON_SMALL_CODE
#endif
#endif
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
{&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
{&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0},
{&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0},
{&__pyx_kp_s_Cannot_assign_to_read_only_memor, __pyx_k_Cannot_assign_to_read_only_memor, sizeof(__pyx_k_Cannot_assign_to_read_only_memor), 0, 0, 1, 0},
{&__pyx_kp_s_Cannot_create_writable_memory_vi, __pyx_k_Cannot_create_writable_memory_vi, sizeof(__pyx_k_Cannot_create_writable_memory_vi), 0, 0, 1, 0},
{&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0},
{&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
{&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0},
{&__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_k_Expected_at_least_d_argument_s_g, sizeof(__pyx_k_Expected_at_least_d_argument_s_g), 0, 0, 1, 0},
{&__pyx_kp_s_Function_call_with_ambiguous_arg, __pyx_k_Function_call_with_ambiguous_arg, sizeof(__pyx_k_Function_call_with_ambiguous_arg), 0, 0, 1, 0},
{&__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0},
{&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
{&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
{&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0},
{&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0},
{&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
{&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0},
{&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
{&__pyx_kp_s_No_matching_signature_found, __pyx_k_No_matching_signature_found, sizeof(__pyx_k_No_matching_signature_found), 0, 0, 1, 0},
{&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
{&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0},
{&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
{&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
{&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0},
{&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
{&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
{&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
{&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
{&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
{&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
{&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
{&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
{&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
{&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
{&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
{&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
{&__pyx_n_s_defaults, __pyx_k_defaults, sizeof(__pyx_k_defaults), 0, 0, 1, 1},
{&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
{&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
{&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
{&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
{&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
{&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
{&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
{&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
{&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
{&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
{&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
{&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
{&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0},
{&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
{&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
{&__pyx_n_s_int, __pyx_k_int, sizeof(__pyx_k_int), 0, 0, 1, 1},
{&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
{&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
{&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
{&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0},
{&__pyx_n_s_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 0, 1, 1},
{&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
{&__pyx_n_s_long, __pyx_k_long, sizeof(__pyx_k_long), 0, 0, 1, 1},
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
{&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
{&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
{&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
{&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
{&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
{&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
{&__pyx_n_s_new_index, __pyx_k_new_index, sizeof(__pyx_k_new_index), 0, 0, 1, 1},
{&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
{&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
{&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
{&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
{&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
{&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
{&__pyx_kp_s_pyapprox_cython_adaptive_sparse, __pyx_k_pyapprox_cython_adaptive_sparse, sizeof(__pyx_k_pyapprox_cython_adaptive_sparse), 0, 0, 1, 0},
{&__pyx_n_s_pyapprox_cython_adaptive_sparse_2, __pyx_k_pyapprox_cython_adaptive_sparse_2, sizeof(__pyx_k_pyapprox_cython_adaptive_sparse_2), 0, 0, 1, 1},
{&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
{&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
{&__pyx_n_s_pyx_fuse_0update_smolyak_coeff, __pyx_k_pyx_fuse_0update_smolyak_coeff, sizeof(__pyx_k_pyx_fuse_0update_smolyak_coeff), 0, 0, 1, 1},
{&__pyx_n_s_pyx_fuse_1update_smolyak_coeff, __pyx_k_pyx_fuse_1update_smolyak_coeff, sizeof(__pyx_k_pyx_fuse_1update_smolyak_coeff), 0, 0, 1, 1},
{&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
{&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
{&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
{&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
{&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
{&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
{&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
{&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
{&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
{&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
{&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
{&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
{&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
{&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
{&__pyx_n_s_signatures, __pyx_k_signatures, sizeof(__pyx_k_signatures), 0, 0, 1, 1},
{&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
{&__pyx_n_s_smolyak_coeffs, __pyx_k_smolyak_coeffs, sizeof(__pyx_k_smolyak_coeffs), 0, 0, 1, 1},
{&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
{&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
{&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
{&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
{&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
{&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0},
{&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
{&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
{&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
{&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
{&__pyx_n_s_subspace_indices, __pyx_k_subspace_indices, sizeof(__pyx_k_subspace_indices), 0, 0, 1, 1},
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
{&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0},
{&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0},
{&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
{&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
{&__pyx_n_s_update_smolyak_coefficients_pyx, __pyx_k_update_smolyak_coefficients_pyx, sizeof(__pyx_k_update_smolyak_coefficients_pyx), 0, 0, 1, 1},
{0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 11, __pyx_L1_error)
__pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 133, __pyx_L1_error)
__pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 148, __pyx_L1_error)
__pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 151, __pyx_L1_error)
__pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 404, __pyx_L1_error)
__pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(1, 613, __pyx_L1_error)
__pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 832, __pyx_L1_error)
return 0;
__pyx_L1_error:;
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":11
* @cython.boundscheck(False) # Deactivate bounds checking
* @cython.wraparound(False) # Deactivate negative indexing.
* cpdef update_smolyak_coefficients_pyx(mixed_type [:] new_index, mixed_type [:,:] subspace_indices, smolyak_coeffs): # <<<<<<<<<<<<<<
*
* if mixed_type is int:
*/
__pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_No_matching_signature_found); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__3);
__Pyx_GIVEREF(__pyx_tuple__3);
__pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Function_call_with_ambiguous_arg); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__4);
__Pyx_GIVEREF(__pyx_tuple__4);
/* "View.MemoryView":133
*
* if not self.ndim:
* raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<<
*
* if itemsize <= 0:
*/
__pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 133, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__5);
__Pyx_GIVEREF(__pyx_tuple__5);
/* "View.MemoryView":136
*
* if itemsize <= 0:
* raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<<
*
* if not isinstance(format, bytes):
*/
__pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 136, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__6);
__Pyx_GIVEREF(__pyx_tuple__6);
/* "View.MemoryView":148
*
* if not self._shape:
* raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 148, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__7);
__Pyx_GIVEREF(__pyx_tuple__7);
/* "View.MemoryView":176
* self.data = <char *>malloc(self.len)
* if not self.data:
* raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
*
* if self.dtype_is_object:
*/
__pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 176, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__8);
__Pyx_GIVEREF(__pyx_tuple__8);
/* "View.MemoryView":192
* bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
* if not (flags & bufmode):
* raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<<
* info.buf = self.data
* info.len = self.len
*/
__pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 192, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__9);
__Pyx_GIVEREF(__pyx_tuple__9);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__10);
__Pyx_GIVEREF(__pyx_tuple__10);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__11);
__Pyx_GIVEREF(__pyx_tuple__11);
/* "View.MemoryView":418
* def __setitem__(memoryview self, object index, object value):
* if self.view.readonly:
* raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<<
*
* have_slices, index = _unellipsify(index, self.view.ndim)
*/
__pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 418, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__12);
__Pyx_GIVEREF(__pyx_tuple__12);
/* "View.MemoryView":495
* result = struct.unpack(self.view.format, bytesitem)
* except struct.error:
* raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<<
* else:
* if len(self.view.format) == 1:
*/
__pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 495, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__13);
__Pyx_GIVEREF(__pyx_tuple__13);
/* "View.MemoryView":520
* def __getbuffer__(self, Py_buffer *info, int flags):
* if flags & PyBUF_WRITABLE and self.view.readonly:
* raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<<
*
* if flags & PyBUF_ND:
*/
__pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 520, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__14);
__Pyx_GIVEREF(__pyx_tuple__14);
/* "View.MemoryView":570
* if self.view.strides == NULL:
*
* raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<<
*
* return tuple([stride for stride in self.view.strides[:self.view.ndim]])
*/
__pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 570, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__15);
__Pyx_GIVEREF(__pyx_tuple__15);
/* "View.MemoryView":577
* def suboffsets(self):
* if self.view.suboffsets == NULL:
* return (-1,) * self.view.ndim # <<<<<<<<<<<<<<
*
* return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
*/
__pyx_tuple__16 = PyTuple_New(1); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__16);
__Pyx_INCREF(__pyx_int_neg_1);
__Pyx_GIVEREF(__pyx_int_neg_1);
PyTuple_SET_ITEM(__pyx_tuple__16, 0, __pyx_int_neg_1);
__Pyx_GIVEREF(__pyx_tuple__16);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__17);
__Pyx_GIVEREF(__pyx_tuple__17);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__18);
__Pyx_GIVEREF(__pyx_tuple__18);
/* "View.MemoryView":682
* if item is Ellipsis:
* if not seen_ellipsis:
* result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<<
* seen_ellipsis = True
* else:
*/
__pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) __PYX_ERR(1, 682, __pyx_L1_error)
__Pyx_GOTREF(__pyx_slice__19);
__Pyx_GIVEREF(__pyx_slice__19);
/* "View.MemoryView":703
* for suboffset in suboffsets[:ndim]:
* if suboffset >= 0:
* raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 703, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__20);
__Pyx_GIVEREF(__pyx_tuple__20);
/* "(tree fragment)":2
* def __reduce_cython__(self):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
*/
__pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 2, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__21);
__Pyx_GIVEREF(__pyx_tuple__21);
/* "(tree fragment)":4
* raise TypeError("no default __reduce__ due to non-trivial __cinit__")
* def __setstate_cython__(self, __pyx_state):
* raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
*/
__pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__22);
__Pyx_GIVEREF(__pyx_tuple__22);
/* "pyapprox/cython/adaptive_sparse_grid.pyx":11
* @cython.boundscheck(False) # Deactivate bounds checking
* @cython.wraparound(False) # Deactivate negative indexing.
* cpdef update_smolyak_coefficients_pyx(mixed_type [:] new_index, mixed_type [:,:] subspace_indices, smolyak_coeffs): # <<<<<<<<<<<<<<
*
* if mixed_type is int:
*/
__pyx_tuple__23 = PyTuple_Pack(3, __pyx_n_s_new_index, __pyx_n_s_subspace_indices, __pyx_n_s_smolyak_coeffs); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__23);
__Pyx_GIVEREF(__pyx_tuple__23);
__pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyapprox_cython_adaptive_sparse, __pyx_n_s_pyx_fuse_0update_smolyak_coeff, 11, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 11, __pyx_L1_error)
/* "View.MemoryView":286
* return self.name
*
* cdef generic = Enum("<strided and direct or indirect>") # <<<<<<<<<<<<<<
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>")
*/
__pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(1, 286, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__25);
__Pyx_GIVEREF(__pyx_tuple__25);
/* "View.MemoryView":287
*
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default # <<<<<<<<<<<<<<
* cdef indirect = Enum("<strided and indirect>")
*
*/
__pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(1, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__26);
__Pyx_GIVEREF(__pyx_tuple__26);
/* "View.MemoryView":288
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(1, 288, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__27);
__Pyx_GIVEREF(__pyx_tuple__27);
/* "View.MemoryView":291
*
*
* cdef contiguous = Enum("<contiguous and direct>") # <<<<<<<<<<<<<<
* cdef indirect_contiguous = Enum("<contiguous and indirect>")
*
*/
__pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(1, 291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__28);
__Pyx_GIVEREF(__pyx_tuple__28);
/* "View.MemoryView":292
*
* cdef contiguous = Enum("<contiguous and direct>")
* cdef indirect_contiguous = Enum("<contiguous and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(1, 292, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__29);
__Pyx_GIVEREF(__pyx_tuple__29);
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_result
*/
__pyx_tuple__30 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__30);
__Pyx_GIVEREF(__pyx_tuple__30);
__pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
__Pyx_RefNannyFinishContext();
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
return 0;
__pyx_L1_error:;
return -1;
}
static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
static int __Pyx_modinit_global_init_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
/*--- Global init code ---*/
generic = Py_None; Py_INCREF(Py_None);
strided = Py_None; Py_INCREF(Py_None);
indirect = Py_None; Py_INCREF(Py_None);
contiguous = Py_None; Py_INCREF(Py_None);
indirect_contiguous = Py_None; Py_INCREF(Py_None);
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_variable_export_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
/*--- Variable export code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_function_export_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
/*--- Function export code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_type_init_code(void) {
__Pyx_RefNannyDeclarations
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
/*--- Type init code ---*/
__pyx_vtabptr_array = &__pyx_vtable_array;
__pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_array.tp_print = 0;
#endif
if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
__pyx_array_type = &__pyx_type___pyx_array;
if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_MemviewEnum.tp_print = 0;
#endif
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
__pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
}
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error)
__pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
__pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
__pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
__pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
__pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
__pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
__pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
__pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
__pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_memoryview.tp_print = 0;
#endif
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
__pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
}
if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error)
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error)
__pyx_memoryview_type = &__pyx_type___pyx_memoryview;
__pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
__pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
__pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
__pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
__pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type___pyx_memoryviewslice.tp_print = 0;
#endif
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
__pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
}
if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error)
if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error)
__pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
__Pyx_RefNannyFinishContext();
return -1;
}
static int __Pyx_modinit_type_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
/*--- Type import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_variable_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
/*--- Variable import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
static int __Pyx_modinit_function_import_code(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
/*--- Function import code ---*/
__Pyx_RefNannyFinishContext();
return 0;
}
#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif
#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initadaptive_sparse_grid(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initadaptive_sparse_grid(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_adaptive_sparse_grid(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_adaptive_sparse_grid(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
#if PY_VERSION_HEX >= 0x030700A1
static PY_INT64_T main_interpreter_id = -1;
PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
if (main_interpreter_id == -1) {
main_interpreter_id = current_id;
return (unlikely(current_id == -1)) ? -1 : 0;
} else if (unlikely(main_interpreter_id != current_id))
#else
static PyInterpreterState *main_interpreter = NULL;
PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
if (!main_interpreter) {
main_interpreter = current_interpreter;
} else if (unlikely(main_interpreter != current_interpreter))
#endif
{
PyErr_SetString(
PyExc_ImportError,
"Interpreter change detected - this module can only be loaded into one interpreter per process.");
return -1;
}
return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
PyObject *value = PyObject_GetAttrString(spec, from_name);
int result = 0;
if (likely(value)) {
if (allow_none || value != Py_None) {
result = PyDict_SetItemString(moddict, to_name, value);
}
Py_DECREF(value);
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Clear();
} else {
result = -1;
}
return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
PyObject *module = NULL, *moddict, *modname;
if (__Pyx_check_single_interpreter())
return NULL;
if (__pyx_m)
return __Pyx_NewRef(__pyx_m);
modname = PyObject_GetAttrString(spec, "name");
if (unlikely(!modname)) goto bad;
module = PyModule_NewObject(modname);
Py_DECREF(modname);
if (unlikely(!module)) goto bad;
moddict = PyModule_GetDict(module);
if (unlikely(!moddict)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
return module;
bad:
Py_XDECREF(module);
return NULL;
}
static CYTHON_SMALL_CODE int __pyx_pymod_exec_adaptive_sparse_grid(PyObject *__pyx_pyinit_module)
#endif
#endif
{
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
static PyThread_type_lock __pyx_t_4[8];
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannyDeclarations
#if CYTHON_PEP489_MULTI_PHASE_INIT
if (__pyx_m) {
if (__pyx_m == __pyx_pyinit_module) return 0;
PyErr_SetString(PyExc_RuntimeError, "Module 'adaptive_sparse_grid' has already been imported. Re-initialisation is not supported.");
return -1;
}
#elif PY_MAJOR_VERSION >= 3
if (__pyx_m) return __Pyx_NewRef(__pyx_m);
#endif
#if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
PyErr_Clear();
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
if (!__Pyx_RefNanny)
Py_FatalError("failed to import 'refnanny' module");
}
#endif
__Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_adaptive_sparse_grid(void)", 0);
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#ifdef __Pxy_PyFrame_Initialize_Offsets
__Pxy_PyFrame_Initialize_Offsets();
#endif
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
#ifdef __Pyx_CyFunction_USED
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_FusedFunction_USED
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_Coroutine_USED
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_Generator_USED
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_AsyncGen_USED
if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
#ifdef __Pyx_StopAsyncIteration_USED
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
/*--- Library function declarations ---*/
/*--- Threads initialization code ---*/
#if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
#ifdef WITH_THREAD /* Python build with threading support? */
PyEval_InitThreads();
#endif
#endif
/*--- Module creation code ---*/
#if CYTHON_PEP489_MULTI_PHASE_INIT
__pyx_m = __pyx_pyinit_module;
Py_INCREF(__pyx_m);
#else
#if PY_MAJOR_VERSION < 3
__pyx_m = Py_InitModule4("adaptive_sparse_grid", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
#else
__pyx_m = PyModule_Create(&__pyx_moduledef);
#endif
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_d);
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_b);
__pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
Py_INCREF(__pyx_cython_runtime);
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
/*--- Initialize various global constants etc. ---*/
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
if (__pyx_module_is_main_pyapprox__cython__adaptive_sparse_grid) {
if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
}
#if PY_MAJOR_VERSION >= 3
{
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
if (!PyDict_GetItemString(modules, "pyapprox.cython.adaptive_sparse_grid")) {
if (unlikely(PyDict_SetItemString(modules, "pyapprox.cython.adaptive_sparse_grid", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
}
}
#endif
/*--- Builtin init code ---*/
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Constants init code ---*/
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Global type/function init code ---*/
(void)__Pyx_modinit_global_init_code();
(void)__Pyx_modinit_variable_export_code();
(void)__Pyx_modinit_function_export_code();
if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
(void)__Pyx_modinit_type_import_code();
(void)__Pyx_modinit_variable_import_code();
(void)__Pyx_modinit_function_import_code();
/*--- Execution code ---*/
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
#endif
/* "pyapprox/cython/adaptive_sparse_grid.pyx":1
* import numpy as np # <<<<<<<<<<<<<<
* import cython
*
*/
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":11
* @cython.boundscheck(False) # Deactivate bounds checking
* @cython.wraparound(False) # Deactivate negative indexing.
* cpdef update_smolyak_coefficients_pyx(mixed_type [:] new_index, mixed_type [:,:] subspace_indices, smolyak_coeffs): # <<<<<<<<<<<<<<
*
* if mixed_type is int:
*/
__pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_8pyapprox_6cython_20adaptive_sparse_grid_3__pyx_fuse_0update_smolyak_coefficients_pyx, 0, __pyx_n_s_pyx_fuse_0update_smolyak_coeff, NULL, __pyx_n_s_pyapprox_cython_adaptive_sparse_2, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_int, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_8pyapprox_6cython_20adaptive_sparse_grid_5__pyx_fuse_1update_smolyak_coefficients_pyx, 0, __pyx_n_s_pyx_fuse_1update_smolyak_coeff, NULL, __pyx_n_s_pyapprox_cython_adaptive_sparse_2, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_long, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __pyx_FusedFunction_New(&__pyx_mdef_8pyapprox_6cython_20adaptive_sparse_grid_1update_smolyak_coefficients_pyx, 0, __pyx_n_s_update_smolyak_coefficients_pyx, NULL, __pyx_n_s_pyapprox_cython_adaptive_sparse_2, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
((__pyx_FusedFunctionObject *) __pyx_t_2)->__signatures__ = __pyx_t_1;
__Pyx_GIVEREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_update_smolyak_coefficients_pyx, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "pyapprox/cython/adaptive_sparse_grid.pyx":1
* import numpy as np # <<<<<<<<<<<<<<
* import cython
*
*/
__pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "View.MemoryView":209
* info.obj = self
*
* __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
* def __dealloc__(array self):
*/
__pyx_t_3 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 209, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_3) < 0) __PYX_ERR(1, 209, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
PyType_Modified(__pyx_array_type);
/* "View.MemoryView":286
* return self.name
*
* cdef generic = Enum("<strided and direct or indirect>") # <<<<<<<<<<<<<<
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>")
*/
__pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 286, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_XGOTREF(generic);
__Pyx_DECREF_SET(generic, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":287
*
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default # <<<<<<<<<<<<<<
* cdef indirect = Enum("<strided and indirect>")
*
*/
__pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_XGOTREF(strided);
__Pyx_DECREF_SET(strided, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":288
* cdef generic = Enum("<strided and direct or indirect>")
* cdef strided = Enum("<strided and direct>") # default
* cdef indirect = Enum("<strided and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 288, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_XGOTREF(indirect);
__Pyx_DECREF_SET(indirect, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":291
*
*
* cdef contiguous = Enum("<contiguous and direct>") # <<<<<<<<<<<<<<
* cdef indirect_contiguous = Enum("<contiguous and indirect>")
*
*/
__pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_XGOTREF(contiguous);
__Pyx_DECREF_SET(contiguous, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":292
*
* cdef contiguous = Enum("<contiguous and direct>")
* cdef indirect_contiguous = Enum("<contiguous and indirect>") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 292, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_XGOTREF(indirect_contiguous);
__Pyx_DECREF_SET(indirect_contiguous, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
/* "View.MemoryView":316
*
* DEF THREAD_LOCKS_PREALLOCATED = 8
* cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<<
* cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
* PyThread_allocate_lock(),
*/
__pyx_memoryview_thread_locks_used = 0;
/* "View.MemoryView":317
* DEF THREAD_LOCKS_PREALLOCATED = 8
* cdef int __pyx_memoryview_thread_locks_used = 0
* cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<<
* PyThread_allocate_lock(),
* PyThread_allocate_lock(),
*/
__pyx_t_4[0] = PyThread_allocate_lock();
__pyx_t_4[1] = PyThread_allocate_lock();
__pyx_t_4[2] = PyThread_allocate_lock();
__pyx_t_4[3] = PyThread_allocate_lock();
__pyx_t_4[4] = PyThread_allocate_lock();
__pyx_t_4[5] = PyThread_allocate_lock();
__pyx_t_4[6] = PyThread_allocate_lock();
__pyx_t_4[7] = PyThread_allocate_lock();
memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_4, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
/* "View.MemoryView":549
* info.obj = self
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 549, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_3) < 0) __PYX_ERR(1, 549, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
PyType_Modified(__pyx_memoryview_type);
/* "View.MemoryView":995
* return self.from_object
*
* __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_3 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 995, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_3) < 0) __PYX_ERR(1, 995, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
PyType_Modified(__pyx_memoryviewslice_type);
/* "(tree fragment)":1
* def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
* cdef object __pyx_PickleError
* cdef object __pyx_result
*/
__pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* "(tree fragment)":11
* __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
* return __pyx_result
* cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
* __pyx_result.name = __pyx_state[0]
* if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
*/
/*--- Wrapped vars code ---*/
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
if (__pyx_m) {
if (__pyx_d) {
__Pyx_AddTraceback("init pyapprox.cython.adaptive_sparse_grid", __pyx_clineno, __pyx_lineno, __pyx_filename);
}
Py_CLEAR(__pyx_m);
} else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ImportError, "init pyapprox.cython.adaptive_sparse_grid");
}
__pyx_L0:;
__Pyx_RefNannyFinishContext();
#if CYTHON_PEP489_MULTI_PHASE_INIT
return (__pyx_m != NULL) ? 0 : -1;
#elif PY_MAJOR_VERSION >= 3
return __pyx_m;
#else
return;
#endif
}
/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
PyObject *m = NULL, *p = NULL;
void *r = NULL;
m = PyImport_ImportModule(modname);
if (!m) goto end;
p = PyObject_GetAttrString(m, "RefNannyAPI");
if (!p) goto end;
r = PyLong_AsVoidPtr(p);
end:
Py_XDECREF(p);
Py_XDECREF(m);
return (__Pyx_RefNannyAPIStruct *)r;
}
#endif
/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
PyTypeObject* tp = Py_TYPE(obj);
if (likely(tp->tp_getattro))
return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
if (likely(tp->tp_getattr))
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
return PyObject_GetAttr(obj, attr_name);
}
#endif
/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
if (unlikely(!result)) {
PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
"name '%U' is not defined", name);
#else
"name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
}
return result;
}
/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
const char* func_name,
int exact,
Py_ssize_t num_min,
Py_ssize_t num_max,
Py_ssize_t num_found)
{
Py_ssize_t num_expected;
const char *more_or_less;
if (num_found < num_min) {
num_expected = num_min;
more_or_less = "at least";
} else {
num_expected = num_max;
more_or_less = "at most";
}
if (exact) {
more_or_less = "exactly";
}
PyErr_Format(PyExc_TypeError,
"%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
func_name, more_or_less, num_expected,
(num_expected == 1) ? "" : "s", num_found);
}
/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
const char* func_name,
PyObject* kw_name)
{
PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION >= 3
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
#else
"%s() got multiple values for keyword argument '%s'", func_name,
PyString_AsString(kw_name));
#endif
}
/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
PyObject *kwds,
PyObject **argnames[],
PyObject *kwds2,
PyObject *values[],
Py_ssize_t num_pos_args,
const char* function_name)
{
PyObject *key = 0, *value = 0;
Py_ssize_t pos = 0;
PyObject*** name;
PyObject*** first_kw_arg = argnames + num_pos_args;
while (PyDict_Next(kwds, &pos, &key, &value)) {
name = first_kw_arg;
while (*name && (**name != key)) name++;
if (*name) {
values[name-argnames] = value;
continue;
}
name = first_kw_arg;
#if PY_MAJOR_VERSION < 3
if (likely(PyString_Check(key))) {
while (*name) {
if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
&& _PyString_Eq(**name, key)) {
values[name-argnames] = value;
break;
}
name++;
}
if (*name) continue;
else {
PyObject*** argname = argnames;
while (argname != first_kw_arg) {
if ((**argname == key) || (
(CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
&& _PyString_Eq(**argname, key))) {
goto arg_passed_twice;
}
argname++;
}
}
} else
#endif
if (likely(PyUnicode_Check(key))) {
while (*name) {
int cmp = (**name == key) ? 0 :
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
(__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
#endif
PyUnicode_Compare(**name, key);
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
if (cmp == 0) {
values[name-argnames] = value;
break;
}
name++;
}
if (*name) continue;
else {
PyObject*** argname = argnames;
while (argname != first_kw_arg) {
int cmp = (**argname == key) ? 0 :
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
(__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
#endif
PyUnicode_Compare(**argname, key);
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
if (cmp == 0) goto arg_passed_twice;
argname++;
}
}
} else
goto invalid_keyword_type;
if (kwds2) {
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
} else {
goto invalid_keyword;
}
}
return 0;
arg_passed_twice:
__Pyx_RaiseDoubleKeywordsError(function_name, key);
goto bad;
invalid_keyword_type:
PyErr_Format(PyExc_TypeError,
"%.200s() keywords must be strings", function_name);
goto bad;
invalid_keyword:
PyErr_Format(PyExc_TypeError,
#if PY_MAJOR_VERSION < 3
"%.200s() got an unexpected keyword argument '%.200s'",
function_name, PyString_AsString(key));
#else
"%s() got an unexpected keyword argument '%U'",
function_name, key);
#endif
bad:
return -1;
}
/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
PyObject *value;
value = PyDict_GetItemWithError(d, key);
if (unlikely(!value)) {
if (!PyErr_Occurred()) {
if (unlikely(PyTuple_Check(key))) {
PyObject* args = PyTuple_Pack(1, key);
if (likely(args)) {
PyErr_SetObject(PyExc_KeyError, args);
Py_DECREF(args);
}
} else {
PyErr_SetObject(PyExc_KeyError, key);
}
}
return NULL;
}
Py_INCREF(value);
return value;
}
#endif
/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
PyObject *self = PyCFunction_GET_SELF(func);
int flags = PyCFunction_GET_FLAGS(func);
assert(PyCFunction_Check(func));
assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
assert(nargs >= 0);
assert(nargs == 0 || args != NULL);
/* _PyCFunction_FastCallDict() must not be called with an exception set,
because it may clear it (directly or indirectly) and so the
caller loses its exception */
assert(!PyErr_Occurred());
if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
} else {
return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
}
}
#endif
/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
PyObject *globals) {
PyFrameObject *f;
PyThreadState *tstate = __Pyx_PyThreadState_Current;
PyObject **fastlocals;
Py_ssize_t i;
PyObject *result;
assert(globals != NULL);
/* XXX Perhaps we should create a specialized
PyFrame_New() that doesn't take locals, but does
take builtins without sanity checking them.
*/
assert(tstate != NULL);
f = PyFrame_New(tstate, co, globals, NULL);
if (f == NULL) {
return NULL;
}
fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
for (i = 0; i < na; i++) {
Py_INCREF(*args);
fastlocals[i] = *args++;
}
result = PyEval_EvalFrameEx(f,0);
++tstate->recursion_depth;
Py_DECREF(f);
--tstate->recursion_depth;
return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
PyObject *globals = PyFunction_GET_GLOBALS(func);
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
PyObject *closure;
#if PY_MAJOR_VERSION >= 3
PyObject *kwdefs;
#endif
PyObject *kwtuple, **k;
PyObject **d;
Py_ssize_t nd;
Py_ssize_t nk;
PyObject *result;
assert(kwargs == NULL || PyDict_Check(kwargs));
nk = kwargs ? PyDict_Size(kwargs) : 0;
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
return NULL;
}
if (
#if PY_MAJOR_VERSION >= 3
co->co_kwonlyargcount == 0 &&
#endif
likely(kwargs == NULL || nk == 0) &&
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
if (argdefs == NULL && co->co_argcount == nargs) {
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
goto done;
}
else if (nargs == 0 && argdefs != NULL
&& co->co_argcount == Py_SIZE(argdefs)) {
/* function called with no arguments, but all parameters have
a default value: use default values as arguments .*/
args = &PyTuple_GET_ITEM(argdefs, 0);
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
goto done;
}
}
if (kwargs != NULL) {
Py_ssize_t pos, i;
kwtuple = PyTuple_New(2 * nk);
if (kwtuple == NULL) {
result = NULL;
goto done;
}
k = &PyTuple_GET_ITEM(kwtuple, 0);
pos = i = 0;
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
Py_INCREF(k[i]);
Py_INCREF(k[i+1]);
i += 2;
}
nk = i / 2;
}
else {
kwtuple = NULL;
k = NULL;
}
closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
if (argdefs != NULL) {
d = &PyTuple_GET_ITEM(argdefs, 0);
nd = Py_SIZE(argdefs);
}
else {
d = NULL;
nd = 0;
}
#if PY_MAJOR_VERSION >= 3
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
args, (int)nargs,
k, (int)nk,
d, (int)nd, kwdefs, closure);
#else
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
args, (int)nargs,
k, (int)nk,
d, (int)nd, closure);
#endif
Py_XDECREF(kwtuple);
done:
Py_LeaveRecursiveCall();
return result;
}
#endif
#endif
/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
PyObject *result;
ternaryfunc call = func->ob_type->tp_call;
if (unlikely(!call))
return PyObject_Call(func, arg, kw);
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
return NULL;
result = (*call)(func, arg, kw);
Py_LeaveRecursiveCall();
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
}
return result;
}
#endif
/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
PyObject *self, *result;
PyCFunction cfunc;
cfunc = PyCFunction_GET_FUNCTION(func);
self = PyCFunction_GET_SELF(func);
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
return NULL;
result = cfunc(self, arg);
Py_LeaveRecursiveCall();
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
}
return result;
}
#endif
/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
PyObject *result;
PyObject *args = PyTuple_New(1);
if (unlikely(!args)) return NULL;
Py_INCREF(arg);
PyTuple_SET_ITEM(args, 0, arg);
result = __Pyx_PyObject_Call(func, args, NULL);
Py_DECREF(args);
return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(func)) {
return __Pyx_PyFunction_FastCall(func, &arg, 1);
}
#endif
if (likely(PyCFunction_Check(func))) {
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
} else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
}
}
return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
PyObject *result;
PyObject *args = PyTuple_Pack(1, arg);
if (unlikely(!args)) return NULL;
result = __Pyx_PyObject_Call(func, args, NULL);
Py_DECREF(args);
return result;
}
#endif
/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
tmp_type = tstate->curexc_type;
tmp_value = tstate->curexc_value;
tmp_tb = tstate->curexc_traceback;
tstate->curexc_type = type;
tstate->curexc_value = value;
tstate->curexc_traceback = tb;
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
*type = tstate->curexc_type;
*value = tstate->curexc_value;
*tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
}
#endif
/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
CYTHON_UNUSED PyObject *cause) {
__Pyx_PyThreadState_declare
Py_XINCREF(type);
if (!value || value == Py_None)
value = NULL;
else
Py_INCREF(value);
if (!tb || tb == Py_None)
tb = NULL;
else {
Py_INCREF(tb);
if (!PyTraceBack_Check(tb)) {
PyErr_SetString(PyExc_TypeError,
"raise: arg 3 must be a traceback or None");
goto raise_error;
}
}
if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
if (!value) {
Py_INCREF(Py_None);
value = Py_None;
}
#endif
PyErr_NormalizeException(&type, &value, &tb);
} else {
if (value) {
PyErr_SetString(PyExc_TypeError,
"instance exception may not have a separate value");
goto raise_error;
}
value = type;
type = (PyObject*) Py_TYPE(type);
Py_INCREF(type);
if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
PyErr_SetString(PyExc_TypeError,
"raise: exception class must be a subclass of BaseException");
goto raise_error;
}
}
__Pyx_PyThreadState_assign
__Pyx_ErrRestore(type, value, tb);
return;
raise_error:
Py_XDECREF(value);
Py_XDECREF(type);
Py_XDECREF(tb);
return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
PyObject* owned_instance = NULL;
if (tb == Py_None) {
tb = 0;
} else if (tb && !PyTraceBack_Check(tb)) {
PyErr_SetString(PyExc_TypeError,
"raise: arg 3 must be a traceback or None");
goto bad;
}
if (value == Py_None)
value = 0;
if (PyExceptionInstance_Check(type)) {
if (value) {
PyErr_SetString(PyExc_TypeError,
"instance exception may not have a separate value");
goto bad;
}
value = type;
type = (PyObject*) Py_TYPE(value);
} else if (PyExceptionClass_Check(type)) {
PyObject *instance_class = NULL;
if (value && PyExceptionInstance_Check(value)) {
instance_class = (PyObject*) Py_TYPE(value);
if (instance_class != type) {
int is_subclass = PyObject_IsSubclass(instance_class, type);
if (!is_subclass) {
instance_class = NULL;
} else if (unlikely(is_subclass == -1)) {
goto bad;
} else {
type = instance_class;
}
}
}
if (!instance_class) {
PyObject *args;
if (!value)
args = PyTuple_New(0);
else if (PyTuple_Check(value)) {
Py_INCREF(value);
args = value;
} else
args = PyTuple_Pack(1, value);
if (!args)
goto bad;
owned_instance = PyObject_Call(type, args, NULL);
Py_DECREF(args);
if (!owned_instance)
goto bad;
value = owned_instance;
if (!PyExceptionInstance_Check(value)) {
PyErr_Format(PyExc_TypeError,
"calling %R should have returned an instance of "
"BaseException, not %R",
type, Py_TYPE(value));
goto bad;
}
}
} else {
PyErr_SetString(PyExc_TypeError,
"raise: exception class must be a subclass of BaseException");
goto bad;
}
if (cause) {
PyObject *fixed_cause;
if (cause == Py_None) {
fixed_cause = NULL;
} else if (PyExceptionClass_Check(cause)) {
fixed_cause = PyObject_CallObject(cause, NULL);
if (fixed_cause == NULL)
goto bad;
} else if (PyExceptionInstance_Check(cause)) {
fixed_cause = cause;
Py_INCREF(fixed_cause);
} else {
PyErr_SetString(PyExc_TypeError,
"exception causes must derive from "
"BaseException");
goto bad;
}
PyException_SetCause(value, fixed_cause);
}
PyErr_SetObject(type, value);
if (tb) {
#if CYTHON_COMPILING_IN_PYPY
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
Py_INCREF(tb);
PyErr_Restore(tmp_type, tmp_value, tb);
Py_XDECREF(tmp_tb);
#else
PyThreadState *tstate = __Pyx_PyThreadState_Current;
PyObject* tmp_tb = tstate->curexc_traceback;
if (tb != tmp_tb) {
Py_INCREF(tb);
tstate->curexc_traceback = tb;
Py_XDECREF(tmp_tb);
}
#endif
}
bad:
Py_XDECREF(owned_instance);
return;
}
#endif
/* UnicodeAsUCS4 */
static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
Py_ssize_t length;
#if CYTHON_PEP393_ENABLED
length = PyUnicode_GET_LENGTH(x);
if (likely(length == 1)) {
return PyUnicode_READ_CHAR(x, 0);
}
#else
length = PyUnicode_GET_SIZE(x);
if (likely(length == 1)) {
return PyUnicode_AS_UNICODE(x)[0];
}
#if Py_UNICODE_SIZE == 2
else if (PyUnicode_GET_SIZE(x) == 2) {
Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
if (high_val >= 0xD800 && high_val <= 0xDBFF) {
Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
}
}
}
#endif
#endif
PyErr_Format(PyExc_ValueError,
"only single character unicode strings can be converted to Py_UCS4, "
"got length %" CYTHON_FORMAT_SSIZE_T "d", length);
return (Py_UCS4)-1;
}
/* object_ord */
static long __Pyx__PyObject_Ord(PyObject* c) {
Py_ssize_t size;
if (PyBytes_Check(c)) {
size = PyBytes_GET_SIZE(c);
if (likely(size == 1)) {
return (unsigned char) PyBytes_AS_STRING(c)[0];
}
#if PY_MAJOR_VERSION < 3
} else if (PyUnicode_Check(c)) {
return (long)__Pyx_PyUnicode_AsPy_UCS4(c);
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
} else if (PyByteArray_Check(c)) {
size = PyByteArray_GET_SIZE(c);
if (likely(size == 1)) {
return (unsigned char) PyByteArray_AS_STRING(c)[0];
}
#endif
} else {
PyErr_Format(PyExc_TypeError,
"ord() expected string of length 1, but %.200s found", c->ob_type->tp_name);
return (long)(Py_UCS4)-1;
}
PyErr_Format(PyExc_TypeError,
"ord() expected a character, but string of length %zd found", size);
return (long)(Py_UCS4)-1;
}
/* SetItemInt */
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
int r;
if (!j) return -1;
r = PyObject_SetItem(o, j, v);
Py_DECREF(j);
return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
if (is_list || PyList_CheckExact(o)) {
Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
PyObject* old = PyList_GET_ITEM(o, n);
Py_INCREF(v);
PyList_SET_ITEM(o, n, v);
Py_DECREF(old);
return 1;
}
} else {
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_ass_item)) {
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
Py_ssize_t l = m->sq_length(o);
if (likely(l >= 0)) {
i += l;
} else {
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
return -1;
PyErr_Clear();
}
}
return m->sq_ass_item(o, i, v);
}
}
#else
#if CYTHON_COMPILING_IN_PYPY
if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
#else
if (is_list || PySequence_Check(o))
#endif
{
return PySequence_SetItem(o, i, v);
}
#endif
return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}
/* IterFinish */
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
PyThreadState *tstate = __Pyx_PyThreadState_Current;
PyObject* exc_type = tstate->curexc_type;
if (unlikely(exc_type)) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
PyObject *exc_value, *exc_tb;
exc_value = tstate->curexc_value;
exc_tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
Py_DECREF(exc_type);
Py_XDECREF(exc_value);
Py_XDECREF(exc_tb);
return 0;
} else {
return -1;
}
}
return 0;
#else
if (unlikely(PyErr_Occurred())) {
if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
PyErr_Clear();
return 0;
} else {
return -1;
}
}
return 0;
#endif
}
/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(func)) {
return __Pyx_PyFunction_FastCall(func, NULL, 0);
}
#endif
#ifdef __Pyx_CyFunction_USED
if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
if (likely(PyCFunction_Check(func)))
#endif
{
if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
return __Pyx_PyObject_CallMethO(func, NULL);
}
}
return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif
/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
PyTypeObject *tp = Py_TYPE(obj);
PyObject *descr;
descrgetfunc f = NULL;
PyObject **dictptr, *dict;
int meth_found = 0;
assert (*method == NULL);
if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
attr = __Pyx_PyObject_GetAttrStr(obj, name);
goto try_unpack;
}
if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
return 0;
}
descr = _PyType_Lookup(tp, name);
if (likely(descr != NULL)) {
Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
#ifdef __Pyx_CyFunction_USED
if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
#else
if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
#endif
#else
#ifdef __Pyx_CyFunction_USED
if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
#else
if (likely(PyFunction_Check(descr)))
#endif
#endif
{
meth_found = 1;
} else {
f = Py_TYPE(descr)->tp_descr_get;
if (f != NULL && PyDescr_IsData(descr)) {
attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
Py_DECREF(descr);
goto try_unpack;
}
}
}
dictptr = _PyObject_GetDictPtr(obj);
if (dictptr != NULL && (dict = *dictptr) != NULL) {
Py_INCREF(dict);
attr = __Pyx_PyDict_GetItemStr(dict, name);
if (attr != NULL) {
Py_INCREF(attr);
Py_DECREF(dict);
Py_XDECREF(descr);
goto try_unpack;
}
Py_DECREF(dict);
}
if (meth_found) {
*method = descr;
return 1;
}
if (f != NULL) {
attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
Py_DECREF(descr);
goto try_unpack;
}
if (descr != NULL) {
*method = descr;
return 0;
}
PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
"'%.50s' object has no attribute '%U'",
tp->tp_name, name);
#else
"'%.50s' object has no attribute '%.400s'",
tp->tp_name, PyString_AS_STRING(name));
#endif
return 0;
#else
attr = __Pyx_PyObject_GetAttrStr(obj, name);
goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
PyObject *function = PyMethod_GET_FUNCTION(attr);
Py_INCREF(function);
Py_DECREF(attr);
*method = function;
return 1;
}
#endif
*method = attr;
return 0;
}
/* PyObjectCallMethod0 */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
PyObject *method = NULL, *result = NULL;
int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
if (likely(is_method)) {
result = __Pyx_PyObject_CallOneArg(method, obj);
Py_DECREF(method);
return result;
}
if (unlikely(!method)) goto bad;
result = __Pyx_PyObject_CallNoArg(method);
Py_DECREF(method);
bad:
return result;
}
/* RaiseNeedMoreValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
PyErr_Format(PyExc_ValueError,
"need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
index, (index == 1) ? "" : "s");
}
/* RaiseTooManyValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
PyErr_Format(PyExc_ValueError,
"too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}
/* UnpackItemEndCheck */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
if (unlikely(retval)) {
Py_DECREF(retval);
__Pyx_RaiseTooManyValuesError(expected);
return -1;
} else {
return __Pyx_IterFinish();
}
return 0;
}
/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}
/* UnpackTupleError */
static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
if (t == Py_None) {
__Pyx_RaiseNoneNotIterableError();
} else if (PyTuple_GET_SIZE(t) < index) {
__Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
} else {
__Pyx_RaiseTooManyValuesError(index);
}
}
/* UnpackTuple2 */
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
PyObject *value1 = NULL, *value2 = NULL;
#if CYTHON_COMPILING_IN_PYPY
value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad;
value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad;
#else
value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1);
value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2);
#endif
if (decref_tuple) {
Py_DECREF(tuple);
}
*pvalue1 = value1;
*pvalue2 = value2;
return 0;
#if CYTHON_COMPILING_IN_PYPY
bad:
Py_XDECREF(value1);
Py_XDECREF(value2);
if (decref_tuple) { Py_XDECREF(tuple); }
return -1;
#endif
}
static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
int has_known_size, int decref_tuple) {
Py_ssize_t index;
PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
iternextfunc iternext;
iter = PyObject_GetIter(tuple);
if (unlikely(!iter)) goto bad;
if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
iternext = Py_TYPE(iter)->tp_iternext;
value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
Py_DECREF(iter);
*pvalue1 = value1;
*pvalue2 = value2;
return 0;
unpacking_failed:
if (!has_known_size && __Pyx_IterFinish() == 0)
__Pyx_RaiseNeedMoreValuesError(index);
bad:
Py_XDECREF(iter);
Py_XDECREF(value1);
Py_XDECREF(value2);
if (decref_tuple) { Py_XDECREF(tuple); }
return -1;
}
/* dict_iter */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
Py_ssize_t* p_orig_length, int* p_source_is_dict) {
is_dict = is_dict || likely(PyDict_CheckExact(iterable));
*p_source_is_dict = is_dict;
if (is_dict) {
#if !CYTHON_COMPILING_IN_PYPY
*p_orig_length = PyDict_Size(iterable);
Py_INCREF(iterable);
return iterable;
#elif PY_MAJOR_VERSION >= 3
static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
PyObject **pp = NULL;
if (method_name) {
const char *name = PyUnicode_AsUTF8(method_name);
if (strcmp(name, "iteritems") == 0) pp = &py_items;
else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
else if (strcmp(name, "itervalues") == 0) pp = &py_values;
if (pp) {
if (!*pp) {
*pp = PyUnicode_FromString(name + 4);
if (!*pp)
return NULL;
}
method_name = *pp;
}
}
#endif
}
*p_orig_length = 0;
if (method_name) {
PyObject* iter;
iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
if (!iterable)
return NULL;
#if !CYTHON_COMPILING_IN_PYPY
if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
return iterable;
#endif
iter = PyObject_GetIter(iterable);
Py_DECREF(iterable);
return iter;
}
return PyObject_GetIter(iterable);
}
static CYTHON_INLINE int __Pyx_dict_iter_next(
PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
PyObject* next_item;
#if !CYTHON_COMPILING_IN_PYPY
if (source_is_dict) {
PyObject *key, *value;
if (unlikely(orig_length != PyDict_Size(iter_obj))) {
PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
return -1;
}
if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
return 0;
}
if (pitem) {
PyObject* tuple = PyTuple_New(2);
if (unlikely(!tuple)) {
return -1;
}
Py_INCREF(key);
Py_INCREF(value);
PyTuple_SET_ITEM(tuple, 0, key);
PyTuple_SET_ITEM(tuple, 1, value);
*pitem = tuple;
} else {
if (pkey) {
Py_INCREF(key);
*pkey = key;
}
if (pvalue) {
Py_INCREF(value);
*pvalue = value;
}
}
return 1;
} else if (PyTuple_CheckExact(iter_obj)) {
Py_ssize_t pos = *ppos;
if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
*ppos = pos + 1;
next_item = PyTuple_GET_ITEM(iter_obj, pos);
Py_INCREF(next_item);
} else if (PyList_CheckExact(iter_obj)) {
Py_ssize_t pos = *ppos;
if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
*ppos = pos + 1;
next_item = PyList_GET_ITEM(iter_obj, pos);
Py_INCREF(next_item);
} else
#endif
{
next_item = PyIter_Next(iter_obj);
if (unlikely(!next_item)) {
return __Pyx_IterFinish();
}
}
if (pitem) {
*pitem = next_item;
} else if (pkey && pvalue) {
if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
return -1;
} else if (pkey) {
*pkey = next_item;
} else {
*pvalue = next_item;
}
return 1;
}
/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
PyObject *args, *result = NULL;
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(function)) {
PyObject *args[2] = {arg1, arg2};
return __Pyx_PyFunction_FastCall(function, args, 2);
}
#endif
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(function)) {
PyObject *args[2] = {arg1, arg2};
return __Pyx_PyCFunction_FastCall(function, args, 2);
}
#endif
args = PyTuple_New(2);
if (unlikely(!args)) goto done;
Py_INCREF(arg1);
PyTuple_SET_ITEM(args, 0, arg1);
Py_INCREF(arg2);
PyTuple_SET_ITEM(args, 1, arg2);
Py_INCREF(function);
result = __Pyx_PyObject_Call(function, args, NULL);
Py_DECREF(args);
Py_DECREF(function);
done:
return result;
}
/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
PyObject *r;
if (!j) return NULL;
r = PyObject_GetItem(o, j);
Py_DECREF(j);
return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
Py_ssize_t wrapped_i = i;
if (wraparound & unlikely(i < 0)) {
wrapped_i += PyList_GET_SIZE(o);
}
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, wrapped_i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
Py_ssize_t wrapped_i = i;
if (wraparound & unlikely(i < 0)) {
wrapped_i += PyTuple_GET_SIZE(o);
}
if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
CYTHON_NCP_UNUSED int wraparound,
CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
if (is_list || PyList_CheckExact(o)) {
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
PyObject *r = PyList_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
}
else if (PyTuple_CheckExact(o)) {
Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
} else {
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_item)) {
if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
Py_ssize_t l = m->sq_length(o);
if (likely(l >= 0)) {
i += l;
} else {
if (!PyErr_ExceptionMatches(PyExc_OverflowError))
return NULL;
PyErr_Clear();
}
}
return m->sq_item(o, i);
}
}
#else
if (is_list || PySequence_Check(o)) {
return PySequence_GetItem(o, i);
}
#endif
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
PyObject *dict = Py_TYPE(obj)->tp_dict;
return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
PyObject **dictptr = NULL;
Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
dictptr = _PyObject_GetDictPtr(obj);
#endif
}
return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
PyObject *dict = Py_TYPE(obj)->tp_dict;
if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
return 0;
return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif
/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
} else if (unlikely(PyErr_Occurred())) {
return NULL;
}
#else
result = PyDict_GetItem(__pyx_d, name);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
}
#endif
#else
result = PyObject_GetItem(__pyx_d, name);
__PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
if (likely(result)) {
return __Pyx_NewRef(result);
}
PyErr_Clear();
#endif
return __Pyx_GetBuiltinName(name);
}
/* MemviewSliceInit */
static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
int ndim,
__Pyx_memviewslice *memviewslice,
int memview_is_new_reference)
{
__Pyx_RefNannyDeclarations
int i, retval=-1;
Py_buffer *buf = &memview->view;
__Pyx_RefNannySetupContext("init_memviewslice", 0);
if (unlikely(memviewslice->memview || memviewslice->data)) {
PyErr_SetString(PyExc_ValueError,
"memviewslice is already initialized!");
goto fail;
}
if (buf->strides) {
for (i = 0; i < ndim; i++) {
memviewslice->strides[i] = buf->strides[i];
}
} else {
Py_ssize_t stride = buf->itemsize;
for (i = ndim - 1; i >= 0; i--) {
memviewslice->strides[i] = stride;
stride *= buf->shape[i];
}
}
for (i = 0; i < ndim; i++) {
memviewslice->shape[i] = buf->shape[i];
if (buf->suboffsets) {
memviewslice->suboffsets[i] = buf->suboffsets[i];
} else {
memviewslice->suboffsets[i] = -1;
}
}
memviewslice->memview = memview;
memviewslice->data = (char *)buf->buf;
if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
Py_INCREF(memview);
}
retval = 0;
goto no_fail;
fail:
memviewslice->memview = 0;
memviewslice->data = 0;
retval = -1;
no_fail:
__Pyx_RefNannyFinishContext();
return retval;
}
#ifndef Py_NO_RETURN
#define Py_NO_RETURN
#endif
static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
va_list vargs;
char msg[200];
#ifdef HAVE_STDARG_PROTOTYPES
va_start(vargs, fmt);
#else
va_start(vargs);
#endif
vsnprintf(msg, 200, fmt, vargs);
va_end(vargs);
Py_FatalError(msg);
}
static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
PyThread_type_lock lock)
{
int result;
PyThread_acquire_lock(lock, 1);
result = (*acquisition_count)++;
PyThread_release_lock(lock);
return result;
}
static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
PyThread_type_lock lock)
{
int result;
PyThread_acquire_lock(lock, 1);
result = (*acquisition_count)--;
PyThread_release_lock(lock);
return result;
}
static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
{
int first_time;
struct __pyx_memoryview_obj *memview = memslice->memview;
if (unlikely(!memview || (PyObject *) memview == Py_None))
return;
if (unlikely(__pyx_get_slice_count(memview) < 0))
__pyx_fatalerror("Acquisition count is %d (line %d)",
__pyx_get_slice_count(memview), lineno);
first_time = __pyx_add_acquisition_count(memview) == 0;
if (unlikely(first_time)) {
if (have_gil) {
Py_INCREF((PyObject *) memview);
} else {
PyGILState_STATE _gilstate = PyGILState_Ensure();
Py_INCREF((PyObject *) memview);
PyGILState_Release(_gilstate);
}
}
}
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
int have_gil, int lineno) {
int last_time;
struct __pyx_memoryview_obj *memview = memslice->memview;
if (unlikely(!memview || (PyObject *) memview == Py_None)) {
memslice->memview = NULL;
return;
}
if (unlikely(__pyx_get_slice_count(memview) <= 0))
__pyx_fatalerror("Acquisition count is %d (line %d)",
__pyx_get_slice_count(memview), lineno);
last_time = __pyx_sub_acquisition_count(memview) == 1;
memslice->data = NULL;
if (unlikely(last_time)) {
if (have_gil) {
Py_CLEAR(memslice->memview);
} else {
PyGILState_STATE _gilstate = PyGILState_Ensure();
Py_CLEAR(memslice->memview);
PyGILState_Release(_gilstate);
}
} else {
memslice->memview = NULL;
}
}
/* None */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}
/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
else if (exact) {
#if PY_MAJOR_VERSION == 2
if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
#endif
}
else {
if (likely(__Pyx_TypeCheck(obj, type))) return 1;
}
PyErr_Format(PyExc_TypeError,
"Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
name, type->tp_name, Py_TYPE(obj)->tp_name);
return 0;
}
/* BytesEquals */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
return PyObject_RichCompareBool(s1, s2, equals);
#else
if (s1 == s2) {
return (equals == Py_EQ);
} else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
const char *ps1, *ps2;
Py_ssize_t length = PyBytes_GET_SIZE(s1);
if (length != PyBytes_GET_SIZE(s2))
return (equals == Py_NE);
ps1 = PyBytes_AS_STRING(s1);
ps2 = PyBytes_AS_STRING(s2);
if (ps1[0] != ps2[0]) {
return (equals == Py_NE);
} else if (length == 1) {
return (equals == Py_EQ);
} else {
int result;
#if CYTHON_USE_UNICODE_INTERNALS
Py_hash_t hash1, hash2;
hash1 = ((PyBytesObject*)s1)->ob_shash;
hash2 = ((PyBytesObject*)s2)->ob_shash;
if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
return (equals == Py_NE);
}
#endif
result = memcmp(ps1, ps2, (size_t)length);
return (equals == Py_EQ) ? (result == 0) : (result != 0);
}
} else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
return (equals == Py_NE);
} else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
return (equals == Py_NE);
} else {
int result;
PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
if (!py_result)
return -1;
result = __Pyx_PyObject_IsTrue(py_result);
Py_DECREF(py_result);
return result;
}
#endif
}
/* UnicodeEquals */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
PyObject* owned_ref = NULL;
#endif
int s1_is_unicode, s2_is_unicode;
if (s1 == s2) {
goto return_eq;
}
s1_is_unicode = PyUnicode_CheckExact(s1);
s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
owned_ref = PyUnicode_FromObject(s2);
if (unlikely(!owned_ref))
return -1;
s2 = owned_ref;
s2_is_unicode = 1;
} else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
owned_ref = PyUnicode_FromObject(s1);
if (unlikely(!owned_ref))
return -1;
s1 = owned_ref;
s1_is_unicode = 1;
} else if (((!s2_is_unicode) & (!s1_is_unicode))) {
return __Pyx_PyBytes_Equals(s1, s2, equals);
}
#endif
if (s1_is_unicode & s2_is_unicode) {
Py_ssize_t length;
int kind;
void *data1, *data2;
if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
return -1;
length = __Pyx_PyUnicode_GET_LENGTH(s1);
if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
goto return_ne;
}
#if CYTHON_USE_UNICODE_INTERNALS
{
Py_hash_t hash1, hash2;
#if CYTHON_PEP393_ENABLED
hash1 = ((PyASCIIObject*)s1)->hash;
hash2 = ((PyASCIIObject*)s2)->hash;
#else
hash1 = ((PyUnicodeObject*)s1)->hash;
hash2 = ((PyUnicodeObject*)s2)->hash;
#endif
if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
goto return_ne;
}
}
#endif
kind = __Pyx_PyUnicode_KIND(s1);
if (kind != __Pyx_PyUnicode_KIND(s2)) {
goto return_ne;
}
data1 = __Pyx_PyUnicode_DATA(s1);
data2 = __Pyx_PyUnicode_DATA(s2);
if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
goto return_ne;
} else if (length == 1) {
goto return_eq;
} else {
int result = memcmp(data1, data2, (size_t)(length * kind));
#if PY_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
return (equals == Py_EQ) ? (result == 0) : (result != 0);
}
} else if ((s1 == Py_None) & s2_is_unicode) {
goto return_ne;
} else if ((s2 == Py_None) & s1_is_unicode) {
goto return_ne;
} else {
int result;
PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
#if PY_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
if (!py_result)
return -1;
result = __Pyx_PyObject_IsTrue(py_result);
Py_DECREF(py_result);
return result;
}
return_eq:
#if PY_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
return (equals == Py_EQ);
return_ne:
#if PY_MAJOR_VERSION < 3
Py_XDECREF(owned_ref);
#endif
return (equals == Py_NE);
#endif
}
/* None */
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
Py_ssize_t q = a / b;
Py_ssize_t r = a - q*b;
q -= ((r != 0) & ((r ^ b) < 0));
return q;
}
/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
if (likely(PyUnicode_Check(n)))
#else
if (likely(PyString_Check(n)))
#endif
return __Pyx_PyObject_GetAttrStr(o, n);
#endif
return PyObject_GetAttr(o, n);
}
/* ObjectGetItem */
#if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
PyObject *runerr;
Py_ssize_t key_value;
PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
if (unlikely(!(m && m->sq_item))) {
PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
return NULL;
}
key_value = __Pyx_PyIndex_AsSsize_t(index);
if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
}
if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
PyErr_Clear();
PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
}
return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
if (likely(m && m->mp_subscript)) {
return m->mp_subscript(obj, key);
}
return __Pyx_PyObject_GetIndex(obj, key);
}
#endif
/* decode_c_string */
static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
const char* cstring, Py_ssize_t start, Py_ssize_t stop,
const char* encoding, const char* errors,
PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
Py_ssize_t length;
if (unlikely((start < 0) | (stop < 0))) {
size_t slen = strlen(cstring);
if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
PyErr_SetString(PyExc_OverflowError,
"c-string too long to convert to Python");
return NULL;
}
length = (Py_ssize_t) slen;
if (start < 0) {
start += length;
if (start < 0)
start = 0;
}
if (stop < 0)
stop += length;
}
if (unlikely(stop <= start))
return PyUnicode_FromUnicode(NULL, 0);
length = stop - start;
cstring += start;
if (decode_func) {
return decode_func(cstring, length, errors);
} else {
return PyUnicode_Decode(cstring, length, encoding, errors);
}
}
/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
Py_ssize_t i, n;
n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
for (i=0; i<n; i++) {
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
}
#endif
for (i=0; i<n; i++) {
if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
}
return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
PyObject *exc_type = tstate->curexc_type;
if (exc_type == err) return 1;
if (unlikely(!exc_type)) return 0;
if (unlikely(PyTuple_Check(err)))
return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif
/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
return NULL;
__Pyx_PyErr_Clear();
Py_INCREF(d);
return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
PyObject *r = __Pyx_GetAttr(o, n);
return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}
/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
if (unlikely(!type)) {
PyErr_SetString(PyExc_SystemError, "Missing type object");
return 0;
}
if (likely(__Pyx_TypeCheck(obj, type)))
return 1;
PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
Py_TYPE(obj)->tp_name, type->tp_name);
return 0;
}
/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
_PyErr_StackItem *exc_info = tstate->exc_info;
while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
exc_info->previous_item != NULL)
{
exc_info = exc_info->previous_item;
}
return exc_info;
}
#endif
/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
*type = exc_info->exc_type;
*value = exc_info->exc_value;
*tb = exc_info->exc_traceback;
#else
*type = tstate->exc_type;
*value = tstate->exc_value;
*tb = tstate->exc_traceback;
#endif
Py_XINCREF(*type);
Py_XINCREF(*value);
Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem *exc_info = tstate->exc_info;
tmp_type = exc_info->exc_type;
tmp_value = exc_info->exc_value;
tmp_tb = exc_info->exc_traceback;
exc_info->exc_type = type;
exc_info->exc_value = value;
exc_info->exc_traceback = tb;
#else
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
tstate->exc_type = type;
tstate->exc_value = value;
tstate->exc_traceback = tb;
#endif
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
}
#endif
/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
PyObject *tmp_type, *tmp_value, *tmp_tb;
local_type = tstate->curexc_type;
local_value = tstate->curexc_value;
local_tb = tstate->curexc_traceback;
tstate->curexc_type = 0;
tstate->curexc_value = 0;
tstate->curexc_traceback = 0;
#else
PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
if (unlikely(tstate->curexc_type))
#else
if (unlikely(PyErr_Occurred()))
#endif
goto bad;
#if PY_MAJOR_VERSION >= 3
if (local_tb) {
if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
goto bad;
}
#endif
Py_XINCREF(local_tb);
Py_XINCREF(local_type);
Py_XINCREF(local_value);
*type = local_type;
*value = local_value;
*tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
#if CYTHON_USE_EXC_INFO_STACK
{
_PyErr_StackItem *exc_info = tstate->exc_info;
tmp_type = exc_info->exc_type;
tmp_value = exc_info->exc_value;
tmp_tb = exc_info->exc_traceback;
exc_info->exc_type = local_type;
exc_info->exc_value = local_value;
exc_info->exc_traceback = local_tb;
}
#else
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
tstate->exc_type = local_type;
tstate->exc_value = local_value;
tstate->exc_traceback = local_tb;
#endif
Py_XDECREF(tmp_type);
Py_XDECREF(tmp_value);
Py_XDECREF(tmp_tb);
#else
PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
return 0;
bad:
*type = 0;
*value = 0;
*tb = 0;
Py_XDECREF(local_type);
Py_XDECREF(local_value);
Py_XDECREF(local_tb);
return -1;
}
/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_USE_EXC_INFO_STACK
_PyErr_StackItem *exc_info = tstate->exc_info;
tmp_type = exc_info->exc_type;
tmp_value = exc_info->exc_value;
tmp_tb = exc_info->exc_traceback;
exc_info->exc_type = *type;
exc_info->exc_value = *value;
exc_info->exc_traceback = *tb;
#else
tmp_type = tstate->exc_type;
tmp_value = tstate->exc_value;
tmp_tb = tstate->exc_traceback;
tstate->exc_type = *type;
tstate->exc_value = *value;
tstate->exc_traceback = *tb;
#endif
*type = tmp_type;
*value = tmp_value;
*tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
PyObject *tmp_type, *tmp_value, *tmp_tb;
PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
PyErr_SetExcInfo(*type, *value, *tb);
*type = tmp_type;
*value = tmp_value;
*tb = tmp_tb;
}
#endif
/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
PyObject *empty_list = 0;
PyObject *module = 0;
PyObject *global_dict = 0;
PyObject *empty_dict = 0;
PyObject *list;
#if PY_MAJOR_VERSION < 3
PyObject *py_import;
py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
if (!py_import)
goto bad;
#endif
if (from_list)
list = from_list;
else {
empty_list = PyList_New(0);
if (!empty_list)
goto bad;
list = empty_list;
}
global_dict = PyModule_GetDict(__pyx_m);
if (!global_dict)
goto bad;
empty_dict = PyDict_New();
if (!empty_dict)
goto bad;
{
#if PY_MAJOR_VERSION >= 3
if (level == -1) {
if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, 1);
if (!module) {
if (!PyErr_ExceptionMatches(PyExc_ImportError))
goto bad;
PyErr_Clear();
}
}
level = 0;
}
#endif
if (!module) {
#if PY_MAJOR_VERSION < 3
PyObject *py_level = PyInt_FromLong(level);
if (!py_level)
goto bad;
module = PyObject_CallFunctionObjArgs(py_import,
name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
Py_DECREF(py_level);
#else
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, level);
#endif
}
}
bad:
#if PY_MAJOR_VERSION < 3
Py_XDECREF(py_import);
#endif
Py_XDECREF(empty_list);
Py_XDECREF(empty_dict);
return module;
}
/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
while (a) {
a = a->tp_base;
if (a == b)
return 1;
}
return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
PyObject *mro;
if (a == b) return 1;
mro = a->tp_mro;
if (likely(mro)) {
Py_ssize_t i, n;
n = PyTuple_GET_SIZE(mro);
for (i = 0; i < n; i++) {
if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
return 1;
}
return 0;
}
return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
PyObject *exception, *value, *tb;
int res;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__Pyx_ErrFetch(&exception, &value, &tb);
res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
if (unlikely(res == -1)) {
PyErr_WriteUnraisable(err);
res = 0;
}
if (!res) {
res = PyObject_IsSubclass(err, exc_type2);
if (unlikely(res == -1)) {
PyErr_WriteUnraisable(err);
res = 0;
}
}
__Pyx_ErrRestore(exception, value, tb);
return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
if (!res) {
res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
}
return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
Py_ssize_t i, n;
assert(PyExceptionClass_Check(exc_type));
n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
for (i=0; i<n; i++) {
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
}
#endif
for (i=0; i<n; i++) {
PyObject *t = PyTuple_GET_ITEM(tuple, i);
#if PY_MAJOR_VERSION < 3
if (likely(exc_type == t)) return 1;
#endif
if (likely(PyExceptionClass_Check(t))) {
if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
} else {
}
}
return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
if (likely(err == exc_type)) return 1;
if (likely(PyExceptionClass_Check(err))) {
if (likely(PyExceptionClass_Check(exc_type))) {
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
} else if (likely(PyTuple_Check(exc_type))) {
return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
} else {
}
}
return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
assert(PyExceptionClass_Check(exc_type1));
assert(PyExceptionClass_Check(exc_type2));
if (likely(err == exc_type1 || err == exc_type2)) return 1;
if (likely(PyExceptionClass_Check(err))) {
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
}
return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif
/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
(void)inplace;
(void)zerodivision_check;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_CheckExact(op1))) {
const long b = intval;
long x;
long a = PyInt_AS_LONG(op1);
x = (long)((unsigned long)a + b);
if (likely((x^a) >= 0 || (x^b) >= 0))
return PyInt_FromLong(x);
return PyLong_Type.tp_as_number->nb_add(op1, op2);
}
#endif
#if CYTHON_USE_PYLONG_INTERNALS
if (likely(PyLong_CheckExact(op1))) {
const long b = intval;
long a, x;
#ifdef HAVE_LONG_LONG
const PY_LONG_LONG llb = intval;
PY_LONG_LONG lla, llx;
#endif
const digit* digits = ((PyLongObject*)op1)->ob_digit;
const Py_ssize_t size = Py_SIZE(op1);
if (likely(__Pyx_sst_abs(size) <= 1)) {
a = likely(size) ? digits[0] : 0;
if (size == -1) a = -a;
} else {
switch (size) {
case -2:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
#ifdef HAVE_LONG_LONG
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
#endif
}
CYTHON_FALLTHROUGH;
case 2:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
#ifdef HAVE_LONG_LONG
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
#endif
}
CYTHON_FALLTHROUGH;
case -3:
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
#ifdef HAVE_LONG_LONG
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
#endif
}
CYTHON_FALLTHROUGH;
case 3:
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
#ifdef HAVE_LONG_LONG
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
#endif
}
CYTHON_FALLTHROUGH;
case -4:
if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
#ifdef HAVE_LONG_LONG
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
#endif
}
CYTHON_FALLTHROUGH;
case 4:
if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
break;
#ifdef HAVE_LONG_LONG
} else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
goto long_long;
#endif
}
CYTHON_FALLTHROUGH;
default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
}
}
x = a + b;
return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
long_long:
llx = lla + llb;
return PyLong_FromLongLong(llx);
#endif
}
#endif
if (PyFloat_CheckExact(op1)) {
const long b = intval;
double a = PyFloat_AS_DOUBLE(op1);
double result;
PyFPE_START_PROTECT("add", return NULL)
result = ((double)a) + (double)b;
PyFPE_END_PROTECT(result)
return PyFloat_FromDouble(result);
}
return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif
/* None */
static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
long q = a / b;
long r = a - q*b;
q -= ((r != 0) & ((r ^ b) < 0));
return q;
}
/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Format(PyExc_ImportError,
#if PY_MAJOR_VERSION < 3
"cannot import name %.230s", PyString_AS_STRING(name));
#else
"cannot import name %S", name);
#endif
}
return value;
}
/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
PyObject *r;
if (unlikely(!__Pyx_PyBaseString_Check(n))) {
PyErr_SetString(PyExc_TypeError,
"hasattr(): attribute name must be string");
return -1;
}
r = __Pyx_GetAttr(o, n);
if (unlikely(!r)) {
PyErr_Clear();
return 0;
} else {
Py_DECREF(r);
return 1;
}
}
/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
"'%.50s' object has no attribute '%U'",
tp->tp_name, attr_name);
#else
"'%.50s' object has no attribute '%.400s'",
tp->tp_name, PyString_AS_STRING(attr_name));
#endif
return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
PyObject *descr;
PyTypeObject *tp = Py_TYPE(obj);
if (unlikely(!PyString_Check(attr_name))) {
return PyObject_GenericGetAttr(obj, attr_name);
}
assert(!tp->tp_dictoffset);
descr = _PyType_Lookup(tp, attr_name);
if (unlikely(!descr)) {
return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
}
Py_INCREF(descr);
#if PY_MAJOR_VERSION < 3
if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
#endif
{
descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
if (unlikely(f)) {
PyObject *res = f(descr, obj, (PyObject *)tp);
Py_DECREF(descr);
return res;
}
}
return descr;
}
#endif
/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
return PyObject_GenericGetAttr(obj, attr_name);
}
return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif
/* SetVTable */
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
if (!ob)
goto bad;
if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
goto bad;
Py_DECREF(ob);
return 0;
bad:
Py_XDECREF(ob);
return -1;
}
/* PyObjectGetAttrStrNoError */
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
__Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
PyTypeObject* tp = Py_TYPE(obj);
if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
}
#endif
result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
if (unlikely(!result)) {
__Pyx_PyObject_GetAttrStr_ClearAttributeError();
}
return result;
}
/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
int ret;
PyObject *name_attr;
name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
if (likely(name_attr)) {
ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
} else {
ret = -1;
}
if (unlikely(ret < 0)) {
PyErr_Clear();
ret = 0;
}
Py_XDECREF(name_attr);
return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
int ret = 0;
PyObject *object_reduce = NULL;
PyObject *object_reduce_ex = NULL;
PyObject *reduce = NULL;
PyObject *reduce_ex = NULL;
PyObject *reduce_cython = NULL;
PyObject *setstate = NULL;
PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#else
if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
if (likely(reduce_cython)) {
ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
} else if (reduce == object_reduce || PyErr_Occurred()) {
goto __PYX_BAD;
}
setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
if (!setstate) PyErr_Clear();
if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
if (likely(setstate_cython)) {
ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
} else if (!setstate || PyErr_Occurred()) {
goto __PYX_BAD;
}
}
PyType_Modified((PyTypeObject*)type_obj);
}
}
goto __PYX_GOOD;
__PYX_BAD:
if (!PyErr_Occurred())
PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
Py_XDECREF(object_reduce);
Py_XDECREF(object_reduce_ex);
#endif
Py_XDECREF(reduce);
Py_XDECREF(reduce_ex);
Py_XDECREF(reduce_cython);
Py_XDECREF(setstate);
Py_XDECREF(setstate_cython);
return ret;
}
/* FetchCommonType */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
PyObject* fake_module;
PyTypeObject* cached_type = NULL;
fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
if (!fake_module) return NULL;
Py_INCREF(fake_module);
cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
if (cached_type) {
if (!PyType_Check((PyObject*)cached_type)) {
PyErr_Format(PyExc_TypeError,
"Shared Cython type %.200s is not a type object",
type->tp_name);
goto bad;
}
if (cached_type->tp_basicsize != type->tp_basicsize) {
PyErr_Format(PyExc_TypeError,
"Shared Cython type %.200s has the wrong size, try recompiling",
type->tp_name);
goto bad;
}
} else {
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
PyErr_Clear();
if (PyType_Ready(type) < 0) goto bad;
if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
goto bad;
Py_INCREF(type);
cached_type = type;
}
done:
Py_DECREF(fake_module);
return cached_type;
bad:
Py_XDECREF(cached_type);
cached_type = NULL;
goto done;
}
/* CythonFunctionShared */
#include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
if (unlikely(op->func_doc == NULL)) {
if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
if (unlikely(op->func_doc == NULL))
return NULL;
} else {
Py_INCREF(Py_None);
return Py_None;
}
}
Py_INCREF(op->func_doc);
return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
PyObject *tmp = op->func_doc;
if (value == NULL) {
value = Py_None;
}
Py_INCREF(value);
op->func_doc = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
if (unlikely(op->func_name == NULL))
return NULL;
}
Py_INCREF(op->func_name);
return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
if (unlikely(value == NULL || !PyString_Check(value)))
#endif
{
PyErr_SetString(PyExc_TypeError,
"__name__ must be set to a string object");
return -1;
}
tmp = op->func_name;
Py_INCREF(value);
op->func_name = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
Py_INCREF(op->func_qualname);
return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
if (unlikely(value == NULL || !PyString_Check(value)))
#endif
{
PyErr_SetString(PyExc_TypeError,
"__qualname__ must be set to a string object");
return -1;
}
tmp = op->func_qualname;
Py_INCREF(value);
op->func_qualname = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
PyObject *self;
self = m->func_closure;
if (self == NULL)
self = Py_None;
Py_INCREF(self);
return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
if (unlikely(op->func_dict == NULL)) {
op->func_dict = PyDict_New();
if (unlikely(op->func_dict == NULL))
return NULL;
}
Py_INCREF(op->func_dict);
return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
PyObject *tmp;
if (unlikely(value == NULL)) {
PyErr_SetString(PyExc_TypeError,
"function's dictionary may not be deleted");
return -1;
}
if (unlikely(!PyDict_Check(value))) {
PyErr_SetString(PyExc_TypeError,
"setting function's dictionary to a non-dict");
return -1;
}
tmp = op->func_dict;
Py_INCREF(value);
op->func_dict = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
Py_INCREF(op->func_globals);
return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
PyObject* result = (op->func_code) ? op->func_code : Py_None;
Py_INCREF(result);
return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
int result = 0;
PyObject *res = op->defaults_getter((PyObject *) op);
if (unlikely(!res))
return -1;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
Py_INCREF(op->defaults_tuple);
op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
Py_INCREF(op->defaults_kwdict);
#else
op->defaults_tuple = PySequence_ITEM(res, 0);
if (unlikely(!op->defaults_tuple)) result = -1;
else {
op->defaults_kwdict = PySequence_ITEM(res, 1);
if (unlikely(!op->defaults_kwdict)) result = -1;
}
#endif
Py_DECREF(res);
return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
PyObject* tmp;
if (!value) {
value = Py_None;
} else if (value != Py_None && !PyTuple_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__defaults__ must be set to a tuple object");
return -1;
}
Py_INCREF(value);
tmp = op->defaults_tuple;
op->defaults_tuple = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
PyObject* result = op->defaults_tuple;
if (unlikely(!result)) {
if (op->defaults_getter) {
if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
result = op->defaults_tuple;
} else {
result = Py_None;
}
}
Py_INCREF(result);
return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
PyObject* tmp;
if (!value) {
value = Py_None;
} else if (value != Py_None && !PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__kwdefaults__ must be set to a dict object");
return -1;
}
Py_INCREF(value);
tmp = op->defaults_kwdict;
op->defaults_kwdict = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
PyObject* result = op->defaults_kwdict;
if (unlikely(!result)) {
if (op->defaults_getter) {
if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
result = op->defaults_kwdict;
} else {
result = Py_None;
}
}
Py_INCREF(result);
return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
PyObject* tmp;
if (!value || value == Py_None) {
value = NULL;
} else if (!PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__annotations__ must be set to a dict object");
return -1;
}
Py_XINCREF(value);
tmp = op->func_annotations;
op->func_annotations = value;
Py_XDECREF(tmp);
return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
PyObject* result = op->func_annotations;
if (unlikely(!result)) {
result = PyDict_New();
if (unlikely(!result)) return NULL;
op->func_annotations = result;
}
Py_INCREF(result);
return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
{(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
{(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
{(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
{(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
{(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
{(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
{(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
{(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
{(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
{(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
{(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
{(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
{(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
{(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
{(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
{(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
{(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
{(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
{0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
{(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
{0, 0, 0, 0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
{"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
{0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
if (unlikely(op == NULL))
return NULL;
op->flags = flags;
__Pyx_CyFunction_weakreflist(op) = NULL;
op->func.m_ml = ml;
op->func.m_self = (PyObject *) op;
Py_XINCREF(closure);
op->func_closure = closure;
Py_XINCREF(module);
op->func.m_module = module;
op->func_dict = NULL;
op->func_name = NULL;
Py_INCREF(qualname);
op->func_qualname = qualname;
op->func_doc = NULL;
op->func_classobj = NULL;
op->func_globals = globals;
Py_INCREF(op->func_globals);
Py_XINCREF(code);
op->func_code = code;
op->defaults_pyobjects = 0;
op->defaults_size = 0;
op->defaults = NULL;
op->defaults_tuple = NULL;
op->defaults_kwdict = NULL;
op->defaults_getter = NULL;
op->func_annotations = NULL;
return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
Py_CLEAR(m->func_closure);
Py_CLEAR(m->func.m_module);
Py_CLEAR(m->func_dict);
Py_CLEAR(m->func_name);
Py_CLEAR(m->func_qualname);
Py_CLEAR(m->func_doc);
Py_CLEAR(m->func_globals);
Py_CLEAR(m->func_code);
Py_CLEAR(m->func_classobj);
Py_CLEAR(m->defaults_tuple);
Py_CLEAR(m->defaults_kwdict);
Py_CLEAR(m->func_annotations);
if (m->defaults) {
PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
int i;
for (i = 0; i < m->defaults_pyobjects; i++)
Py_XDECREF(pydefaults[i]);
PyObject_Free(m->defaults);
m->defaults = NULL;
}
return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
if (__Pyx_CyFunction_weakreflist(m) != NULL)
PyObject_ClearWeakRefs((PyObject *) m);
__Pyx_CyFunction_clear(m);
PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
PyObject_GC_UnTrack(m);
__Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
Py_VISIT(m->func_closure);
Py_VISIT(m->func.m_module);
Py_VISIT(m->func_dict);
Py_VISIT(m->func_name);
Py_VISIT(m->func_qualname);
Py_VISIT(m->func_doc);
Py_VISIT(m->func_globals);
Py_VISIT(m->func_code);
Py_VISIT(m->func_classobj);
Py_VISIT(m->defaults_tuple);
Py_VISIT(m->defaults_kwdict);
if (m->defaults) {
PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
int i;
for (i = 0; i < m->defaults_pyobjects; i++)
Py_VISIT(pydefaults[i]);
}
return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
Py_INCREF(func);
return func;
}
if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
if (type == NULL)
type = (PyObject *)(Py_TYPE(obj));
return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
}
if (obj == Py_None)
obj = NULL;
return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromFormat("<cyfunction %U at %p>",
op->func_qualname, (void *)op);
#else
return PyString_FromFormat("<cyfunction %s at %p>",
PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
PyCFunctionObject* f = (PyCFunctionObject*)func;
PyCFunction meth = f->m_ml->ml_meth;
Py_ssize_t size;
switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
case METH_VARARGS:
if (likely(kw == NULL || PyDict_Size(kw) == 0))
return (*meth)(self, arg);
break;
case METH_VARARGS | METH_KEYWORDS:
return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
case METH_NOARGS:
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
size = PyTuple_GET_SIZE(arg);
if (likely(size == 0))
return (*meth)(self, NULL);
PyErr_Format(PyExc_TypeError,
"%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
f->m_ml->ml_name, size);
return NULL;
}
break;
case METH_O:
if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
size = PyTuple_GET_SIZE(arg);
if (likely(size == 1)) {
PyObject *result, *arg0;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
arg0 = PyTuple_GET_ITEM(arg, 0);
#else
arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
#endif
result = (*meth)(self, arg0);
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
Py_DECREF(arg0);
#endif
return result;
}
PyErr_Format(PyExc_TypeError,
"%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
f->m_ml->ml_name, size);
return NULL;
}
break;
default:
PyErr_SetString(PyExc_SystemError, "Bad call flags in "
"__Pyx_CyFunction_Call. METH_OLDARGS is no "
"longer supported!");
return NULL;
}
PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
f->m_ml->ml_name);
return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
PyObject *result;
__pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
Py_ssize_t argc;
PyObject *new_args;
PyObject *self;
argc = PyTuple_GET_SIZE(args);
new_args = PyTuple_GetSlice(args, 1, argc);
if (unlikely(!new_args))
return NULL;
self = PyTuple_GetItem(args, 0);
if (unlikely(!self)) {
Py_DECREF(new_args);
return NULL;
}
result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
Py_DECREF(new_args);
} else {
result = __Pyx_CyFunction_Call(func, args, kw);
}
return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
PyVarObject_HEAD_INIT(0, 0)
"cython_function_or_method",
sizeof(__pyx_CyFunctionObject),
0,
(destructor) __Pyx_CyFunction_dealloc,
0,
0,
0,
#if PY_MAJOR_VERSION < 3
0,
#else
0,
#endif
(reprfunc) __Pyx_CyFunction_repr,
0,
0,
0,
0,
__Pyx_CyFunction_CallAsMethod,
0,
0,
0,
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
0,
(traverseproc) __Pyx_CyFunction_traverse,
(inquiry) __Pyx_CyFunction_clear,
0,
#if PY_VERSION_HEX < 0x030500A0
offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
offsetof(PyCFunctionObject, m_weakreflist),
#endif
0,
0,
__pyx_CyFunction_methods,
__pyx_CyFunction_members,
__pyx_CyFunction_getsets,
0,
0,
__Pyx_CyFunction_descr_get,
0,
offsetof(__pyx_CyFunctionObject, func_dict),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
#if PY_VERSION_HEX >= 0x030400a1
0,
#endif
#if PY_VERSION_HEX >= 0x030800b1
0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0,
#endif
};
static int __pyx_CyFunction_init(void) {
__pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
if (unlikely(__pyx_CyFunctionType == NULL)) {
return -1;
}
return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults = PyObject_Malloc(size);
if (unlikely(!m->defaults))
return PyErr_NoMemory();
memset(m->defaults, 0, size);
m->defaults_pyobjects = pyobjects;
m->defaults_size = size;
return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults_tuple = tuple;
Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->defaults_kwdict = dict;
Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
__pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
m->func_annotations = dict;
Py_INCREF(dict);
}
/* FusedFunction */
static PyObject *
__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
PyObject *qualname, PyObject *closure,
PyObject *module, PyObject *globals,
PyObject *code)
{
PyObject *op = __Pyx_CyFunction_Init(
PyObject_GC_New(__pyx_CyFunctionObject, __pyx_FusedFunctionType),
ml, flags, qualname, closure, module, globals, code
);
if (likely(op)) {
__pyx_FusedFunctionObject *fusedfunc = (__pyx_FusedFunctionObject *) op;
fusedfunc->__signatures__ = NULL;
fusedfunc->type = NULL;
fusedfunc->self = NULL;
PyObject_GC_Track(op);
}
return op;
}
static void
__pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self)
{
PyObject_GC_UnTrack(self);
Py_CLEAR(self->self);
Py_CLEAR(self->type);
Py_CLEAR(self->__signatures__);
__Pyx__CyFunction_dealloc((__pyx_CyFunctionObject *) self);
}
static int
__pyx_FusedFunction_traverse(__pyx_FusedFunctionObject *self,
visitproc visit,
void *arg)
{
Py_VISIT(self->self);
Py_VISIT(self->type);
Py_VISIT(self->__signatures__);
return __Pyx_CyFunction_traverse((__pyx_CyFunctionObject *) self, visit, arg);
}
static int
__pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self)
{
Py_CLEAR(self->self);
Py_CLEAR(self->type);
Py_CLEAR(self->__signatures__);
return __Pyx_CyFunction_clear((__pyx_CyFunctionObject *) self);
}
static PyObject *
__pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{
__pyx_FusedFunctionObject *func, *meth;
func = (__pyx_FusedFunctionObject *) self;
if (func->self || func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD) {
Py_INCREF(self);
return self;
}
if (obj == Py_None)
obj = NULL;
meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_New(
((PyCFunctionObject *) func)->m_ml,
((__pyx_CyFunctionObject *) func)->flags,
((__pyx_CyFunctionObject *) func)->func_qualname,
((__pyx_CyFunctionObject *) func)->func_closure,
((PyCFunctionObject *) func)->m_module,
((__pyx_CyFunctionObject *) func)->func_globals,
((__pyx_CyFunctionObject *) func)->func_code);
if (!meth)
return NULL;
if (func->func.defaults) {
PyObject **pydefaults;
int i;
if (!__Pyx_CyFunction_InitDefaults((PyObject*)meth,
func->func.defaults_size,
func->func.defaults_pyobjects)) {
Py_XDECREF((PyObject*)meth);
return NULL;
}
memcpy(meth->func.defaults, func->func.defaults, func->func.defaults_size);
pydefaults = __Pyx_CyFunction_Defaults(PyObject *, meth);
for (i = 0; i < meth->func.defaults_pyobjects; i++)
Py_XINCREF(pydefaults[i]);
}
Py_XINCREF(func->func.func_classobj);
meth->func.func_classobj = func->func.func_classobj;
Py_XINCREF(func->__signatures__);
meth->__signatures__ = func->__signatures__;
Py_XINCREF(type);
meth->type = type;
Py_XINCREF(func->func.defaults_tuple);
meth->func.defaults_tuple = func->func.defaults_tuple;
if (func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD)
obj = type;
Py_XINCREF(obj);
meth->self = obj;
return (PyObject *) meth;
}
static PyObject *
_obj_to_str(PyObject *obj)
{
if (PyType_Check(obj))
return PyObject_GetAttr(obj, __pyx_n_s_name_2);
else
return PyObject_Str(obj);
}
static PyObject *
__pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
{
PyObject *signature = NULL;
PyObject *unbound_result_func;
PyObject *result_func = NULL;
if (self->__signatures__ == NULL) {
PyErr_SetString(PyExc_TypeError, "Function is not fused");
return NULL;
}
if (PyTuple_Check(idx)) {
PyObject *list = PyList_New(0);
Py_ssize_t n = PyTuple_GET_SIZE(idx);
PyObject *sep = NULL;
int i;
if (unlikely(!list))
return NULL;
for (i = 0; i < n; i++) {
int ret;
PyObject *string;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
PyObject *item = PyTuple_GET_ITEM(idx, i);
#else
PyObject *item = PySequence_ITEM(idx, i); if (unlikely(!item)) goto __pyx_err;
#endif
string = _obj_to_str(item);
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
Py_DECREF(item);
#endif
if (unlikely(!string)) goto __pyx_err;
ret = PyList_Append(list, string);
Py_DECREF(string);
if (unlikely(ret < 0)) goto __pyx_err;
}
sep = PyUnicode_FromString("|");
if (likely(sep))
signature = PyUnicode_Join(sep, list);
__pyx_err:
;
Py_DECREF(list);
Py_XDECREF(sep);
} else {
signature = _obj_to_str(idx);
}
if (!signature)
return NULL;
unbound_result_func = PyObject_GetItem(self->__signatures__, signature);
if (unbound_result_func) {
if (self->self || self->type) {
__pyx_FusedFunctionObject *unbound = (__pyx_FusedFunctionObject *) unbound_result_func;
Py_CLEAR(unbound->func.func_classobj);
Py_XINCREF(self->func.func_classobj);
unbound->func.func_classobj = self->func.func_classobj;
result_func = __pyx_FusedFunction_descr_get(unbound_result_func,
self->self, self->type);
} else {
result_func = unbound_result_func;
Py_INCREF(result_func);
}
}
Py_DECREF(signature);
Py_XDECREF(unbound_result_func);
return result_func;
}
static PyObject *
__pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
{
__pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD &&
!((__pyx_FusedFunctionObject *) func)->__signatures__);
if (cyfunc->flags & __Pyx_CYFUNCTION_CCLASS && !static_specialized) {
return __Pyx_CyFunction_CallAsMethod(func, args, kw);
} else {
return __Pyx_CyFunction_Call(func, args, kw);
}
}
static PyObject *
__pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
{
__pyx_FusedFunctionObject *binding_func = (__pyx_FusedFunctionObject *) func;
Py_ssize_t argc = PyTuple_GET_SIZE(args);
PyObject *new_args = NULL;
__pyx_FusedFunctionObject *new_func = NULL;
PyObject *result = NULL;
PyObject *self = NULL;
int is_staticmethod = binding_func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD;
int is_classmethod = binding_func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD;
if (binding_func->self) {
Py_ssize_t i;
new_args = PyTuple_New(argc + 1);
if (!new_args)
return NULL;
self = binding_func->self;
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
Py_INCREF(self);
#endif
Py_INCREF(self);
PyTuple_SET_ITEM(new_args, 0, self);
for (i = 0; i < argc; i++) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
PyObject *item = PyTuple_GET_ITEM(args, i);
Py_INCREF(item);
#else
PyObject *item = PySequence_ITEM(args, i); if (unlikely(!item)) goto bad;
#endif
PyTuple_SET_ITEM(new_args, i + 1, item);
}
args = new_args;
} else if (binding_func->type) {
if (argc < 1) {
PyErr_SetString(PyExc_TypeError, "Need at least one argument, 0 given.");
return NULL;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
self = PyTuple_GET_ITEM(args, 0);
#else
self = PySequence_ITEM(args, 0); if (unlikely(!self)) return NULL;
#endif
}
if (self && !is_classmethod && !is_staticmethod) {
int is_instance = PyObject_IsInstance(self, binding_func->type);
if (unlikely(!is_instance)) {
PyErr_Format(PyExc_TypeError,
"First argument should be of type %.200s, got %.200s.",
((PyTypeObject *) binding_func->type)->tp_name,
self->ob_type->tp_name);
goto bad;
} else if (unlikely(is_instance == -1)) {
goto bad;
}
}
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
Py_XDECREF(self);
self = NULL;
#endif
if (binding_func->__signatures__) {
PyObject *tup;
if (is_staticmethod && binding_func->func.flags & __Pyx_CYFUNCTION_CCLASS) {
tup = PyTuple_Pack(3, args,
kw == NULL ? Py_None : kw,
binding_func->func.defaults_tuple);
if (unlikely(!tup)) goto bad;
new_func = (__pyx_FusedFunctionObject *) __Pyx_CyFunction_CallMethod(
func, binding_func->__signatures__, tup, NULL);
} else {
tup = PyTuple_Pack(4, binding_func->__signatures__, args,
kw == NULL ? Py_None : kw,
binding_func->func.defaults_tuple);
if (unlikely(!tup)) goto bad;
new_func = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_callfunction(func, tup, NULL);
}
Py_DECREF(tup);
if (unlikely(!new_func))
goto bad;
Py_XINCREF(binding_func->func.func_classobj);
Py_CLEAR(new_func->func.func_classobj);
new_func->func.func_classobj = binding_func->func.func_classobj;
func = (PyObject *) new_func;
}
result = __pyx_FusedFunction_callfunction(func, args, kw);
bad:
#if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
Py_XDECREF(self);
#endif
Py_XDECREF(new_args);
Py_XDECREF((PyObject *) new_func);
return result;
}
static PyMemberDef __pyx_FusedFunction_members[] = {
{(char *) "__signatures__",
T_OBJECT,
offsetof(__pyx_FusedFunctionObject, __signatures__),
READONLY,
0},
{0, 0, 0, 0, 0},
};
static PyMappingMethods __pyx_FusedFunction_mapping_methods = {
0,
(binaryfunc) __pyx_FusedFunction_getitem,
0,
};
static PyTypeObject __pyx_FusedFunctionType_type = {
PyVarObject_HEAD_INIT(0, 0)
"fused_cython_function",
sizeof(__pyx_FusedFunctionObject),
0,
(destructor) __pyx_FusedFunction_dealloc,
0,
0,
0,
#if PY_MAJOR_VERSION < 3
0,
#else
0,
#endif
0,
0,
0,
&__pyx_FusedFunction_mapping_methods,
0,
(ternaryfunc) __pyx_FusedFunction_call,
0,
0,
0,
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
0,
(traverseproc) __pyx_FusedFunction_traverse,
(inquiry) __pyx_FusedFunction_clear,
0,
0,
0,
0,
0,
__pyx_FusedFunction_members,
__pyx_CyFunction_getsets,
&__pyx_CyFunctionType_type,
0,
__pyx_FusedFunction_descr_get,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
#if PY_VERSION_HEX >= 0x030400a1
0,
#endif
#if PY_VERSION_HEX >= 0x030800b1
0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
0,
#endif
};
static int __pyx_FusedFunction_init(void) {
__pyx_FusedFunctionType_type.tp_base = __pyx_CyFunctionType;
__pyx_FusedFunctionType = __Pyx_FetchCommonType(&__pyx_FusedFunctionType_type);
if (__pyx_FusedFunctionType == NULL) {
return -1;
}
return 0;
}
/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
PyObject *use_cline;
PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
PyObject **cython_runtime_dict;
#endif
if (unlikely(!__pyx_cython_runtime)) {
return c_line;
}
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
if (likely(cython_runtime_dict)) {
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
use_cline, *cython_runtime_dict,
__Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
} else
#endif
{
PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
if (use_cline_obj) {
use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
Py_DECREF(use_cline_obj);
} else {
PyErr_Clear();
use_cline = NULL;
}
}
if (!use_cline) {
c_line = 0;
PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
}
else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
c_line = 0;
}
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
return c_line;
}
#endif
/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
int start = 0, mid = 0, end = count - 1;
if (end >= 0 && code_line > entries[end].code_line) {
return count;
}
while (start < end) {
mid = start + (end - start) / 2;
if (code_line < entries[mid].code_line) {
end = mid;
} else if (code_line > entries[mid].code_line) {
start = mid + 1;
} else {
return mid;
}
}
if (code_line <= entries[mid].code_line) {
return mid;
} else {
return mid + 1;
}
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
PyCodeObject* code_object;
int pos;
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
return NULL;
}
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
return NULL;
}
code_object = __pyx_code_cache.entries[pos].code_object;
Py_INCREF(code_object);
return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
int pos, i;
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
if (unlikely(!code_line)) {
return;
}
if (unlikely(!entries)) {
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
if (likely(entries)) {
__pyx_code_cache.entries = entries;
__pyx_code_cache.max_count = 64;
__pyx_code_cache.count = 1;
entries[0].code_line = code_line;
entries[0].code_object = code_object;
Py_INCREF(code_object);
}
return;
}
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
PyCodeObject* tmp = entries[pos].code_object;
entries[pos].code_object = code_object;
Py_DECREF(tmp);
return;
}
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
int new_max = __pyx_code_cache.max_count + 64;
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
__pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
if (unlikely(!entries)) {
return;
}
__pyx_code_cache.entries = entries;
__pyx_code_cache.max_count = new_max;
}
for (i=__pyx_code_cache.count; i>pos; i--) {
entries[i] = entries[i-1];
}
entries[pos].code_line = code_line;
entries[pos].code_object = code_object;
__pyx_code_cache.count++;
Py_INCREF(code_object);
}
/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
const char *funcname, int c_line,
int py_line, const char *filename) {
PyCodeObject *py_code = 0;
PyObject *py_srcfile = 0;
PyObject *py_funcname = 0;
#if PY_MAJOR_VERSION < 3
py_srcfile = PyString_FromString(filename);
#else
py_srcfile = PyUnicode_FromString(filename);
#endif
if (!py_srcfile) goto bad;
if (c_line) {
#if PY_MAJOR_VERSION < 3
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
#else
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
#endif
}
else {
#if PY_MAJOR_VERSION < 3
py_funcname = PyString_FromString(funcname);
#else
py_funcname = PyUnicode_FromString(funcname);
#endif
}
if (!py_funcname) goto bad;
py_code = __Pyx_PyCode_New(
0,
0,
0,
0,
0,
__pyx_empty_bytes, /*PyObject *code,*/
__pyx_empty_tuple, /*PyObject *consts,*/
__pyx_empty_tuple, /*PyObject *names,*/
__pyx_empty_tuple, /*PyObject *varnames,*/
__pyx_empty_tuple, /*PyObject *freevars,*/
__pyx_empty_tuple, /*PyObject *cellvars,*/
py_srcfile, /*PyObject *filename,*/
py_funcname, /*PyObject *name,*/
py_line,
__pyx_empty_bytes /*PyObject *lnotab*/
);
Py_DECREF(py_srcfile);
Py_DECREF(py_funcname);
return py_code;
bad:
Py_XDECREF(py_srcfile);
Py_XDECREF(py_funcname);
return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename) {
PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0;
PyThreadState *tstate = __Pyx_PyThreadState_Current;
if (c_line) {
c_line = __Pyx_CLineForTraceback(tstate, c_line);
}
py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
if (!py_code) {
py_code = __Pyx_CreateCodeObjectForTraceback(
funcname, c_line, py_line, filename);
if (!py_code) goto bad;
__pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
}
py_frame = PyFrame_New(
tstate, /*PyThreadState *tstate,*/
py_code, /*PyCodeObject *code,*/
__pyx_d, /*PyObject *globals,*/
0 /*PyObject *locals*/
);
if (!py_frame) goto bad;
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
PyTraceBack_Here(py_frame);
bad:
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
}
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
PyObject *obj = view->obj;
if (!obj) return;
if (PyObject_CheckBuffer(obj)) {
PyBuffer_Release(view);
return;
}
if ((0)) {}
view->obj = NULL;
Py_DECREF(obj);
}
#endif
/* MemviewSliceIsContig */
static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim)
{
int i, index, step, start;
Py_ssize_t itemsize = mvs.memview->view.itemsize;
if (order == 'F') {
step = 1;
start = 0;
} else {
step = -1;
start = ndim - 1;
}
for (i = 0; i < ndim; i++) {
index = start + step * i;
if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
return 0;
itemsize *= mvs.shape[index];
}
return 1;
}
/* OverlappingSlices */
static void
__pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
void **out_start, void **out_end,
int ndim, size_t itemsize)
{
char *start, *end;
int i;
start = end = slice->data;
for (i = 0; i < ndim; i++) {
Py_ssize_t stride = slice->strides[i];
Py_ssize_t extent = slice->shape[i];
if (extent == 0) {
*out_start = *out_end = start;
return;
} else {
if (stride > 0)
end += stride * (extent - 1);
else
start += stride * (extent - 1);
}
}
*out_start = start;
*out_end = end + itemsize;
}
static int
__pyx_slices_overlap(__Pyx_memviewslice *slice1,
__Pyx_memviewslice *slice2,
int ndim, size_t itemsize)
{
void *start1, *end1, *start2, *end2;
__pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
__pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
return (start1 < end2) && (start2 < end1);
}
/* Capsule */
static CYTHON_INLINE PyObject *
__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
{
PyObject *cobj;
#if PY_VERSION_HEX >= 0x02070000
cobj = PyCapsule_New(p, sig, NULL);
#else
cobj = PyCObject_FromVoidPtr(p, NULL);
#endif
return cobj;
}
/* IsLittleEndian */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
{
union {
uint32_t u32;
uint8_t u8[4];
} S;
S.u32 = 0x01020304;
return S.u8[0] == 4;
}
/* BufferFormatCheck */
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
__Pyx_BufFmt_StackElem* stack,
__Pyx_TypeInfo* type) {
stack[0].field = &ctx->root;
stack[0].parent_offset = 0;
ctx->root.type = type;
ctx->root.name = "buffer dtype";
ctx->root.offset = 0;
ctx->head = stack;
ctx->head->field = &ctx->root;
ctx->fmt_offset = 0;
ctx->head->parent_offset = 0;
ctx->new_packmode = '@';
ctx->enc_packmode = '@';
ctx->new_count = 1;
ctx->enc_count = 0;
ctx->enc_type = 0;
ctx->is_complex = 0;
ctx->is_valid_array = 0;
ctx->struct_alignment = 0;
while (type->typegroup == 'S') {
++ctx->head;
ctx->head->field = type->fields;
ctx->head->parent_offset = 0;
type = type->fields->type;
}
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
int count;
const char* t = *ts;
if (*t < '0' || *t > '9') {
return -1;
} else {
count = *t++ - '0';
while (*t >= '0' && *t <= '9') {
count *= 10;
count += *t++ - '0';
}
}
*ts = t;
return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
int number = __Pyx_BufFmt_ParseNumber(ts);
if (number == -1)
PyErr_Format(PyExc_ValueError,\
"Does not understand character buffer dtype format string ('%c')", **ts);
return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
PyErr_Format(PyExc_ValueError,
"Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
switch (ch) {
case '?': return "'bool'";
case 'c': return "'char'";
case 'b': return "'signed char'";
case 'B': return "'unsigned char'";
case 'h': return "'short'";
case 'H': return "'unsigned short'";
case 'i': return "'int'";
case 'I': return "'unsigned int'";
case 'l': return "'long'";
case 'L': return "'unsigned long'";
case 'q': return "'long long'";
case 'Q': return "'unsigned long long'";
case 'f': return (is_complex ? "'complex float'" : "'float'");
case 'd': return (is_complex ? "'complex double'" : "'double'");
case 'g': return (is_complex ? "'complex long double'" : "'long double'");
case 'T': return "a struct";
case 'O': return "Python object";
case 'P': return "a pointer";
case 's': case 'p': return "a string";
case 0: return "end";
default: return "unparseable format string";
}
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
switch (ch) {
case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return 2;
case 'i': case 'I': case 'l': case 'L': return 4;
case 'q': case 'Q': return 8;
case 'f': return (is_complex ? 8 : 4);
case 'd': return (is_complex ? 16 : 8);
case 'g': {
PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
return 0;
}
case 'O': case 'P': return sizeof(void*);
default:
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
switch (ch) {
case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return sizeof(short);
case 'i': case 'I': return sizeof(int);
case 'l': case 'L': return sizeof(long);
#ifdef HAVE_LONG_LONG
case 'q': case 'Q': return sizeof(PY_LONG_LONG);
#endif
case 'f': return sizeof(float) * (is_complex ? 2 : 1);
case 'd': return sizeof(double) * (is_complex ? 2 : 1);
case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
case 'O': case 'P': return sizeof(void*);
default: {
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
switch (ch) {
case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
default:
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
/* These are for computing the padding at the end of the struct to align
on the first member of the struct. This will probably the same as above,
but we don't have any guarantees.
*/
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
switch (ch) {
case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
default:
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
switch (ch) {
case 'c':
return 'H';
case 'b': case 'h': case 'i':
case 'l': case 'q': case 's': case 'p':
return 'I';
case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
return 'U';
case 'f': case 'd': case 'g':
return (is_complex ? 'C' : 'R');
case 'O':
return 'O';
case 'P':
return 'P';
default: {
__Pyx_BufFmt_RaiseUnexpectedChar(ch);
return 0;
}
}
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
if (ctx->head == NULL || ctx->head->field == &ctx->root) {
const char* expected;
const char* quote;
if (ctx->head == NULL) {
expected = "end";
quote = "";
} else {
expected = ctx->head->field->type->name;
quote = "'";
}
PyErr_Format(PyExc_ValueError,
"Buffer dtype mismatch, expected %s%s%s but got %s",
quote, expected, quote,
__Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
} else {
__Pyx_StructField* field = ctx->head->field;
__Pyx_StructField* parent = (ctx->head - 1)->field;
PyErr_Format(PyExc_ValueError,
"Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
parent->type->name, field->name);
}
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
char group;
size_t size, offset, arraysize = 1;
if (ctx->enc_type == 0) return 0;
if (ctx->head->field->type->arraysize[0]) {
int i, ndim = 0;
if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
ctx->is_valid_array = ctx->head->field->type->ndim == 1;
ndim = 1;
if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
PyErr_Format(PyExc_ValueError,
"Expected a dimension of size %zu, got %zu",
ctx->head->field->type->arraysize[0], ctx->enc_count);
return -1;
}
}
if (!ctx->is_valid_array) {
PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
ctx->head->field->type->ndim, ndim);
return -1;
}
for (i = 0; i < ctx->head->field->type->ndim; i++) {
arraysize *= ctx->head->field->type->arraysize[i];
}
ctx->is_valid_array = 0;
ctx->enc_count = 1;
}
group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
do {
__Pyx_StructField* field = ctx->head->field;
__Pyx_TypeInfo* type = field->type;
if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
} else {
size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
}
if (ctx->enc_packmode == '@') {
size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
size_t align_mod_offset;
if (align_at == 0) return -1;
align_mod_offset = ctx->fmt_offset % align_at;
if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
if (ctx->struct_alignment == 0)
ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
ctx->is_complex);
}
if (type->size != size || type->typegroup != group) {
if (type->typegroup == 'C' && type->fields != NULL) {
size_t parent_offset = ctx->head->parent_offset + field->offset;
++ctx->head;
ctx->head->field = type->fields;
ctx->head->parent_offset = parent_offset;
continue;
}
if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
} else {
__Pyx_BufFmt_RaiseExpected(ctx);
return -1;
}
}
offset = ctx->head->parent_offset + field->offset;
if (ctx->fmt_offset != offset) {
PyErr_Format(PyExc_ValueError,
"Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
(Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
return -1;
}
ctx->fmt_offset += size;
if (arraysize)
ctx->fmt_offset += (arraysize - 1) * size;
--ctx->enc_count;
while (1) {
if (field == &ctx->root) {
ctx->head = NULL;
if (ctx->enc_count != 0) {
__Pyx_BufFmt_RaiseExpected(ctx);
return -1;
}
break;
}
ctx->head->field = ++field;
if (field->type == NULL) {
--ctx->head;
field = ctx->head->field;
continue;
} else if (field->type->typegroup == 'S') {
size_t parent_offset = ctx->head->parent_offset + field->offset;
if (field->type->fields->type == NULL) continue;
field = field->type->fields;
++ctx->head;
ctx->head->field = field;
ctx->head->parent_offset = parent_offset;
break;
} else {
break;
}
}
} while (ctx->enc_count);
ctx->enc_type = 0;
ctx->is_complex = 0;
return 0;
}
static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
const char *ts = *tsp;
int i = 0, number, ndim;
++ts;
if (ctx->new_count != 1) {
PyErr_SetString(PyExc_ValueError,
"Cannot handle repeated arrays in format string");
return NULL;
}
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ndim = ctx->head->field->type->ndim;
while (*ts && *ts != ')') {
switch (*ts) {
case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue;
default: break;
}
number = __Pyx_BufFmt_ExpectNumber(&ts);
if (number == -1) return NULL;
if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
return PyErr_Format(PyExc_ValueError,
"Expected a dimension of size %zu, got %d",
ctx->head->field->type->arraysize[i], number);
if (*ts != ',' && *ts != ')')
return PyErr_Format(PyExc_ValueError,
"Expected a comma in format string, got '%c'", *ts);
if (*ts == ',') ts++;
i++;
}
if (i != ndim)
return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
ctx->head->field->type->ndim, i);
if (!*ts) {
PyErr_SetString(PyExc_ValueError,
"Unexpected end of format string, expected ')'");
return NULL;
}
ctx->is_valid_array = 1;
ctx->new_count = 1;
*tsp = ++ts;
return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
int got_Z = 0;
while (1) {
switch(*ts) {
case 0:
if (ctx->enc_type != 0 && ctx->head == NULL) {
__Pyx_BufFmt_RaiseExpected(ctx);
return NULL;
}
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
if (ctx->head != NULL) {
__Pyx_BufFmt_RaiseExpected(ctx);
return NULL;
}
return ts;
case ' ':
case '\r':
case '\n':
++ts;
break;
case '<':
if (!__Pyx_Is_Little_Endian()) {
PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
return NULL;
}
ctx->new_packmode = '=';
++ts;
break;
case '>':
case '!':
if (__Pyx_Is_Little_Endian()) {
PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
return NULL;
}
ctx->new_packmode = '=';
++ts;
break;
case '=':
case '@':
case '^':
ctx->new_packmode = *ts++;
break;
case 'T':
{
const char* ts_after_sub;
size_t i, struct_count = ctx->new_count;
size_t struct_alignment = ctx->struct_alignment;
ctx->new_count = 1;
++ts;
if (*ts != '{') {
PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
return NULL;
}
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->enc_type = 0;
ctx->enc_count = 0;
ctx->struct_alignment = 0;
++ts;
ts_after_sub = ts;
for (i = 0; i != struct_count; ++i) {
ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
if (!ts_after_sub) return NULL;
}
ts = ts_after_sub;
if (struct_alignment) ctx->struct_alignment = struct_alignment;
}
break;
case '}':
{
size_t alignment = ctx->struct_alignment;
++ts;
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->enc_type = 0;
if (alignment && ctx->fmt_offset % alignment) {
ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
}
}
return ts;
case 'x':
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->fmt_offset += ctx->new_count;
ctx->new_count = 1;
ctx->enc_count = 0;
ctx->enc_type = 0;
ctx->enc_packmode = ctx->new_packmode;
++ts;
break;
case 'Z':
got_Z = 1;
++ts;
if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
__Pyx_BufFmt_RaiseUnexpectedChar('Z');
return NULL;
}
CYTHON_FALLTHROUGH;
case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
case 'l': case 'L': case 'q': case 'Q':
case 'f': case 'd': case 'g':
case 'O': case 'p':
if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
(ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
ctx->enc_count += ctx->new_count;
ctx->new_count = 1;
got_Z = 0;
++ts;
break;
}
CYTHON_FALLTHROUGH;
case 's':
if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
ctx->enc_count = ctx->new_count;
ctx->enc_packmode = ctx->new_packmode;
ctx->enc_type = *ts;
ctx->is_complex = got_Z;
++ts;
ctx->new_count = 1;
got_Z = 0;
break;
case ':':
++ts;
while(*ts != ':') ++ts;
++ts;
break;
case '(':
if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
break;
default:
{
int number = __Pyx_BufFmt_ExpectNumber(&ts);
if (number == -1) return NULL;
ctx->new_count = (size_t)number;
}
}
}
}
/* TypeInfoCompare */
static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
{
int i;
if (!a || !b)
return 0;
if (a == b)
return 1;
if (a->size != b->size || a->typegroup != b->typegroup ||
a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
if (a->typegroup == 'H' || b->typegroup == 'H') {
return a->size == b->size;
} else {
return 0;
}
}
if (a->ndim) {
for (i = 0; i < a->ndim; i++)
if (a->arraysize[i] != b->arraysize[i])
return 0;
}
if (a->typegroup == 'S') {
if (a->flags != b->flags)
return 0;
if (a->fields || b->fields) {
if (!(a->fields && b->fields))
return 0;
for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
__Pyx_StructField *field_a = a->fields + i;
__Pyx_StructField *field_b = b->fields + i;
if (field_a->offset != field_b->offset ||
!__pyx_typeinfo_cmp(field_a->type, field_b->type))
return 0;
}
return !a->fields[i].type && !b->fields[i].type;
}
}
return 1;
}
/* MemviewSliceValidateAndInit */
static int
__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
{
if (buf->shape[dim] <= 1)
return 1;
if (buf->strides) {
if (spec & __Pyx_MEMVIEW_CONTIG) {
if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
if (unlikely(buf->strides[dim] != sizeof(void *))) {
PyErr_Format(PyExc_ValueError,
"Buffer is not indirectly contiguous "
"in dimension %d.", dim);
goto fail;
}
} else if (unlikely(buf->strides[dim] != buf->itemsize)) {
PyErr_SetString(PyExc_ValueError,
"Buffer and memoryview are not contiguous "
"in the same dimension.");
goto fail;
}
}
if (spec & __Pyx_MEMVIEW_FOLLOW) {
Py_ssize_t stride = buf->strides[dim];
if (stride < 0)
stride = -stride;
if (unlikely(stride < buf->itemsize)) {
PyErr_SetString(PyExc_ValueError,
"Buffer and memoryview are not contiguous "
"in the same dimension.");
goto fail;
}
}
} else {
if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) {
PyErr_Format(PyExc_ValueError,
"C-contiguous buffer is not contiguous in "
"dimension %d", dim);
goto fail;
} else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) {
PyErr_Format(PyExc_ValueError,
"C-contiguous buffer is not indirect in "
"dimension %d", dim);
goto fail;
} else if (unlikely(buf->suboffsets)) {
PyErr_SetString(PyExc_ValueError,
"Buffer exposes suboffsets but no strides");
goto fail;
}
}
return 1;
fail:
return 0;
}
static int
__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
{
if (spec & __Pyx_MEMVIEW_DIRECT) {
if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) {
PyErr_Format(PyExc_ValueError,
"Buffer not compatible with direct access "
"in dimension %d.", dim);
goto fail;
}
}
if (spec & __Pyx_MEMVIEW_PTR) {
if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) {
PyErr_Format(PyExc_ValueError,
"Buffer is not indirectly accessible "
"in dimension %d.", dim);
goto fail;
}
}
return 1;
fail:
return 0;
}
static int
__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
{
int i;
if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
Py_ssize_t stride = 1;
for (i = 0; i < ndim; i++) {
if (unlikely(stride * buf->itemsize != buf->strides[i] && buf->shape[i] > 1)) {
PyErr_SetString(PyExc_ValueError,
"Buffer not fortran contiguous.");
goto fail;
}
stride = stride * buf->shape[i];
}
} else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
Py_ssize_t stride = 1;
for (i = ndim - 1; i >- 1; i--) {
if (unlikely(stride * buf->itemsize != buf->strides[i] && buf->shape[i] > 1)) {
PyErr_SetString(PyExc_ValueError,
"Buffer not C contiguous.");
goto fail;
}
stride = stride * buf->shape[i];
}
}
return 1;
fail:
return 0;
}
static int __Pyx_ValidateAndInit_memviewslice(
int *axes_specs,
int c_or_f_flag,
int buf_flags,
int ndim,
__Pyx_TypeInfo *dtype,
__Pyx_BufFmt_StackElem stack[],
__Pyx_memviewslice *memviewslice,
PyObject *original_obj)
{
struct __pyx_memoryview_obj *memview, *new_memview;
__Pyx_RefNannyDeclarations
Py_buffer *buf;
int i, spec = 0, retval = -1;
__Pyx_BufFmt_Context ctx;
int from_memoryview = __pyx_memoryview_check(original_obj);
__Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
original_obj)->typeinfo)) {
memview = (struct __pyx_memoryview_obj *) original_obj;
new_memview = NULL;
} else {
memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
original_obj, buf_flags, 0, dtype);
new_memview = memview;
if (unlikely(!memview))
goto fail;
}
buf = &memview->view;
if (unlikely(buf->ndim != ndim)) {
PyErr_Format(PyExc_ValueError,
"Buffer has wrong number of dimensions (expected %d, got %d)",
ndim, buf->ndim);
goto fail;
}
if (new_memview) {
__Pyx_BufFmt_Init(&ctx, stack, dtype);
if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail;
}
if (unlikely((unsigned) buf->itemsize != dtype->size)) {
PyErr_Format(PyExc_ValueError,
"Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
"does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
buf->itemsize,
(buf->itemsize > 1) ? "s" : "",
dtype->name,
dtype->size,
(dtype->size > 1) ? "s" : "");
goto fail;
}
for (i = 0; i < ndim; i++) {
spec = axes_specs[i];
if (unlikely(!__pyx_check_strides(buf, i, ndim, spec)))
goto fail;
if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec)))
goto fail;
}
if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)))
goto fail;
if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
new_memview != NULL) == -1)) {
goto fail;
}
retval = 0;
goto no_fail;
fail:
Py_XDECREF(new_memview);
retval = -1;
no_fail:
__Pyx_RefNannyFinishContext();
return retval;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 1,
&__Pyx_TypeInfo_int, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_long(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 1,
&__Pyx_TypeInfo_long, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_int(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 2,
&__Pyx_TypeInfo_int, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_long(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 2,
&__Pyx_TypeInfo_long, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(long) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(long) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
}
} else {
if (sizeof(long) <= sizeof(long)) {
return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(long),
little, !is_unsigned);
}
}
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
const int is_unsigned = neg_one > const_zero;
if (is_unsigned) {
if (sizeof(int) < sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof(int) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
}
} else {
if (sizeof(int) <= sizeof(long)) {
return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
}
}
{
int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&value;
return _PyLong_FromByteArray(bytes, sizeof(int),
little, !is_unsigned);
}
}
/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
{\
func_type value = func_value;\
if (sizeof(target_type) < sizeof(func_type)) {\
if (unlikely(value != (func_type) (target_type) value)) {\
func_type zero = 0;\
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
return (target_type) -1;\
if (is_unsigned && unlikely(value < zero))\
goto raise_neg_overflow;\
else\
goto raise_overflow;\
}\
}\
return (target_type) value;\
}
/* MemviewSliceCopyTemplate */
static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
const char *mode, int ndim,
size_t sizeof_dtype, int contig_flag,
int dtype_is_object)
{
__Pyx_RefNannyDeclarations
int i;
__Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
Py_buffer *buf = &from_memview->view;
PyObject *shape_tuple = NULL;
PyObject *temp_int = NULL;
struct __pyx_array_obj *array_obj = NULL;
struct __pyx_memoryview_obj *memview_obj = NULL;
__Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
for (i = 0; i < ndim; i++) {
if (unlikely(from_mvs->suboffsets[i] >= 0)) {
PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
"indirect dimensions (axis %d)", i);
goto fail;
}
}
shape_tuple = PyTuple_New(ndim);
if (unlikely(!shape_tuple)) {
goto fail;
}
__Pyx_GOTREF(shape_tuple);
for(i = 0; i < ndim; i++) {
temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
if(unlikely(!temp_int)) {
goto fail;
} else {
PyTuple_SET_ITEM(shape_tuple, i, temp_int);
temp_int = NULL;
}
}
array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
if (unlikely(!array_obj)) {
goto fail;
}
__Pyx_GOTREF(array_obj);
memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
(PyObject *) array_obj, contig_flag,
dtype_is_object,
from_mvs->memview->typeinfo);
if (unlikely(!memview_obj))
goto fail;
if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
goto fail;
if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
dtype_is_object) < 0))
goto fail;
goto no_fail;
fail:
__Pyx_XDECREF(new_mvs.memview);
new_mvs.memview = NULL;
new_mvs.data = NULL;
no_fail:
__Pyx_XDECREF(shape_tuple);
__Pyx_XDECREF(temp_int);
__Pyx_XDECREF(array_obj);
__Pyx_RefNannyFinishContext();
return new_mvs;
}
/* BytesContains */
static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) {
const Py_ssize_t length = PyBytes_GET_SIZE(bytes);
char* char_start = PyBytes_AS_STRING(bytes);
return memchr(char_start, (unsigned char)character, (size_t)length) != NULL;
}
/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(int) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (int) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int) 0;
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
case 2:
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (int) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(int) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (int) 0;
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
case -2:
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
}
}
break;
}
#endif
if (sizeof(int) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
int val;
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (int) -1;
}
} else {
int val;
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
if (!tmp) return (int) -1;
val = __Pyx_PyInt_As_int(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to int");
return (int) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to int");
return (int) -1;
}
/* ImportNumPyArray */
static PyObject* __Pyx__ImportNumPyArray(void) {
PyObject *numpy_module, *ndarray_object = NULL;
numpy_module = __Pyx_Import(__pyx_n_s_numpy, NULL, 0);
if (likely(numpy_module)) {
ndarray_object = PyObject_GetAttrString(numpy_module, "ndarray");
Py_DECREF(numpy_module);
}
if (unlikely(!ndarray_object)) {
PyErr_Clear();
}
if (unlikely(!ndarray_object || !PyObject_TypeCheck(ndarray_object, &PyType_Type))) {
Py_XDECREF(ndarray_object);
Py_INCREF(Py_None);
ndarray_object = Py_None;
}
return ndarray_object;
}
static CYTHON_INLINE PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void) {
if (unlikely(!__pyx_numpy_ndarray)) {
__pyx_numpy_ndarray = __Pyx__ImportNumPyArray();
}
Py_INCREF(__pyx_numpy_ndarray);
return __pyx_numpy_ndarray;
}
/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(long) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (long) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (long) 0;
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
case 2:
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (long) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(long) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (long) 0;
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
case -2:
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
}
}
break;
}
#endif
if (sizeof(long) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
long val;
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (long) -1;
}
} else {
long val;
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
if (!tmp) return (long) -1;
val = __Pyx_PyInt_As_long(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to long");
return (long) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to long");
return (long) -1;
}
/* CIntFromPy */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
const char neg_one = (char) ((char) 0 - (char) 1), const_zero = (char) 0;
const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x))) {
if (sizeof(char) < sizeof(long)) {
__PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
} else {
long val = PyInt_AS_LONG(x);
if (is_unsigned && unlikely(val < 0)) {
goto raise_neg_overflow;
}
return (char) val;
}
} else
#endif
if (likely(PyLong_Check(x))) {
if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (char) 0;
case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
case 2:
if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
}
}
break;
case 3:
if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
}
}
break;
case 4:
if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
}
}
break;
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON
if (unlikely(Py_SIZE(x) < 0)) {
goto raise_neg_overflow;
}
#else
{
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
if (unlikely(result < 0))
return (char) -1;
if (unlikely(result == 1))
goto raise_neg_overflow;
}
#endif
if (sizeof(char) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
}
} else {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)x)->ob_digit;
switch (Py_SIZE(x)) {
case 0: return (char) 0;
case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0])
case -2:
if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case 2:
if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case -3:
if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case 3:
if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case -4:
if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
case 4:
if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
__PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
} else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
}
}
break;
}
#endif
if (sizeof(char) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
} else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
}
}
{
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
PyErr_SetString(PyExc_RuntimeError,
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
char val;
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
#if PY_MAJOR_VERSION < 3
if (likely(v) && !PyLong_Check(v)) {
PyObject *tmp = v;
v = PyNumber_Long(tmp);
Py_DECREF(tmp);
}
#endif
if (likely(v)) {
int one = 1; int is_little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val;
int ret = _PyLong_AsByteArray((PyLongObject *)v,
bytes, sizeof(val),
is_little, !is_unsigned);
Py_DECREF(v);
if (likely(!ret))
return val;
}
#endif
return (char) -1;
}
} else {
char val;
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
if (!tmp) return (char) -1;
val = __Pyx_PyInt_As_char(tmp);
Py_DECREF(tmp);
return val;
}
raise_overflow:
PyErr_SetString(PyExc_OverflowError,
"value too large to convert to char");
return (char) -1;
raise_neg_overflow:
PyErr_SetString(PyExc_OverflowError,
"can't convert negative value to char");
return (char) -1;
}
/* ObjectToMemviewSlice */
static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_double(PyObject *obj, int writable_flag) {
__Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_BufFmt_StackElem stack[1];
int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
int retcode;
if (obj == Py_None) {
result.memview = (struct __pyx_memoryview_obj *) Py_None;
return result;
}
retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
PyBUF_RECORDS_RO | writable_flag, 1,
&__Pyx_TypeInfo_double, stack,
&result, obj);
if (unlikely(retcode == -1))
goto __pyx_fail;
return result;
__pyx_fail:
result.memview = NULL;
result.data = NULL;
return result;
}
/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
char ctversion[4], rtversion[4];
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
char message[200];
PyOS_snprintf(message, sizeof(message),
"compiletime version %s of module '%.100s' "
"does not match runtime version %s",
ctversion, __Pyx_MODULE_NAME, rtversion);
return PyErr_WarnEx(NULL, message, 1);
}
return 0;
}
/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
while (t->p) {
#if PY_MAJOR_VERSION < 3
if (t->is_unicode) {
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
} else if (t->intern) {
*t->p = PyString_InternFromString(t->s);
} else {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
}
#else
if (t->is_unicode | t->is_str) {
if (t->intern) {
*t->p = PyUnicode_InternFromString(t->s);
} else if (t->encoding) {
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
} else {
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
}
} else {
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
}
#endif
if (!*t->p)
return -1;
if (PyObject_Hash(*t->p) == -1)
return -1;
++t;
}
return 0;
}
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
Py_ssize_t ignore;
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
char* defenc_c;
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
if (!defenc) return NULL;
defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
{
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
char* c;
for (c = defenc_c; c < end; c++) {
if ((unsigned char) (*c) >= 128) {
PyUnicode_AsASCIIString(o);
return NULL;
}
}
}
#endif
*length = PyBytes_GET_SIZE(defenc);
return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
if (likely(PyUnicode_IS_ASCII(o))) {
*length = PyUnicode_GET_LENGTH(o);
return PyUnicode_AsUTF8(o);
} else {
PyUnicode_AsASCIIString(o);
return NULL;
}
#else
return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
__Pyx_sys_getdefaultencoding_not_ascii &&
#endif
PyUnicode_Check(o)) {
return __Pyx_PyUnicode_AsStringAndSize(o, length);
} else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
if (PyByteArray_Check(o)) {
*length = PyByteArray_GET_SIZE(o);
return PyByteArray_AS_STRING(o);
} else
#endif
{
char* result;
int r = PyBytes_AsStringAndSize(o, &result, length);
if (unlikely(r < 0)) {
return NULL;
} else {
return result;
}
}
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
int is_true = x == Py_True;
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
int retval;
if (unlikely(!x)) return -1;
retval = __Pyx_PyObject_IsTrue(x);
Py_DECREF(x);
return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
if (PyLong_Check(result)) {
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
"__int__ returned non-int (type %.200s). "
"The ability to return an instance of a strict subclass of int "
"is deprecated, and may be removed in a future version of Python.",
Py_TYPE(result)->tp_name)) {
Py_DECREF(result);
return NULL;
}
return result;
}
#endif
PyErr_Format(PyExc_TypeError,
"__%.4s__ returned non-%.4s (type %.200s)",
type_name, type_name, Py_TYPE(result)->tp_name);
Py_DECREF(result);
return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
PyNumberMethods *m;
#endif
const char *name = NULL;
PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
if (likely(PyLong_Check(x)))
#endif
return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
if (m && m->nb_int) {
name = "int";
res = m->nb_int(x);
}
else if (m && m->nb_long) {
name = "long";
res = m->nb_long(x);
}
#else
if (likely(m && m->nb_int)) {
name = "int";
res = m->nb_int(x);
}
#endif
#else
if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
res = PyNumber_Int(x);
}
#endif
if (likely(res)) {
#if PY_MAJOR_VERSION < 3
if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
if (unlikely(!PyLong_CheckExact(res))) {
#endif
return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
}
}
else if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError,
"an integer is required");
}
return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
Py_ssize_t ival;
PyObject *x;
#if PY_MAJOR_VERSION < 3
if (likely(PyInt_CheckExact(b))) {
if (sizeof(Py_ssize_t) >= sizeof(long))
return PyInt_AS_LONG(b);
else
return PyInt_AsSsize_t(b);
}
#endif
if (likely(PyLong_CheckExact(b))) {
#if CYTHON_USE_PYLONG_INTERNALS
const digit* digits = ((PyLongObject*)b)->ob_digit;
const Py_ssize_t size = Py_SIZE(b);
if (likely(__Pyx_sst_abs(size) <= 1)) {
ival = likely(size) ? digits[0] : 0;
if (size == -1) ival = -ival;
return ival;
} else {
switch (size) {
case 2:
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -2:
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case 3:
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -3:
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case 4:
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
case -4:
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
}
break;
}
}
#endif
return PyLong_AsSsize_t(b);
}
x = PyNumber_Index(b);
if (!x) return -1;
ival = PyInt_AsSsize_t(x);
Py_DECREF(x);
return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
return PyInt_FromSize_t(ival);
}
#endif /* Py_PYTHON_H */
| [
"29109026+jdjakem@users.noreply.github.com"
] | 29109026+jdjakem@users.noreply.github.com |
f8678cdf1e479be6cfe4ed669873b897ddd5f1a0 | 82394d0609c9b521ca5e339819aadee0f015ede5 | /src/key_event.h | 5d18592b382713191fea614633f0d0fecac197c5 | [
"MIT"
] | permissive | eamars/2014S2-ENCE260 | 3e70546aae66783223434c40c2d2368a451d529d | 5c17173b3676c5743e8e0354bd003ebb6055a76a | refs/heads/master | 2020-07-02T00:49:09.372006 | 2014-12-24T04:18:31 | 2014-12-24T04:18:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 566 | h | /** @file key_event.h
@author Ran Bao (rba90) & Kane Williams (pkw21), Group1
@date 7 October 2014
@brief key press header file
*/
#ifndef KEY_EVENT_H
#define KEY_EVENT_H
#include "system.h"
#define BUTTON_TASK_RATE 50
uint8_t nav_north_pushed;
uint8_t nav_south_pushed;
uint8_t nav_west_pushed;
uint8_t nav_east_pushed;
uint8_t nav_pushed;
uint8_t button_pushed;
/**
* initilize all nav keys and button
*/
void key_event_init(void);
/**
* use scheduler to take the press event of nav keys and button
*/
void key_event_p(void);
#endif | [
"worksev@gmail.com"
] | worksev@gmail.com |
e3c37467ff2317db3b0da5fe7e7f63606db4e923 | 607e69f9e4440ef3ab9c33b7b6e85e95b5e982fb | /deps/museum/6.0.1/bionic/libc/kernel/uapi/linux/flat.h | 187fcd497440ba39d3393d9598675149a16206cd | [
"Apache-2.0"
] | permissive | simpleton/profilo | 8bda2ebf057036a55efd4dea1564b1f114229d1a | 91ef4ba1a8316bad2b3080210316dfef4761e180 | refs/heads/master | 2023-03-12T13:34:27.037783 | 2018-04-24T22:45:58 | 2018-04-24T22:45:58 | 125,419,173 | 0 | 0 | Apache-2.0 | 2018-03-15T19:54:00 | 2018-03-15T19:54:00 | null | UTF-8 | C | false | false | 2,153 | h | /****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
*** To edit the content of this header, modify the corresponding
*** source file (e.g. under external/kernel-headers/original/) then
*** run bionic/libc/kernel/tools/update_all.py
***
*** Any manual change here will be lost the next time this script will
*** be run. You've been warned!
***
****************************************************************************
****************************************************************************/
#ifndef _UAPI_LINUX_FLAT_H
#define _UAPI_LINUX_FLAT_H
#define UAPI_LINUX_FLAT_H
#define UAPI_LINUX_FLAT_H_
#define _LINUX_FLAT_H
#define _LINUX_FLAT_H_
#define _UAPI_LINUX_FLAT_H_
#define FLAT_VERSION 0x00000004L
#define MAX_SHARED_LIBS (1)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
struct flat_hdr {
char magic[4];
unsigned long rev;
unsigned long entry;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long data_start;
unsigned long data_end;
unsigned long bss_end;
unsigned long stack_size;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long reloc_start;
unsigned long reloc_count;
unsigned long flags;
unsigned long build_date;
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
unsigned long filler[5];
};
#define FLAT_FLAG_RAM 0x0001
#define FLAT_FLAG_GOTPIC 0x0002
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define FLAT_FLAG_GZIP 0x0004
#define FLAT_FLAG_GZDATA 0x0008
#define FLAT_FLAG_KTRACE 0x0010
#endif
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
309c02e85c03683fc84597a9ad6141a3157d6c91 | b9ce299a0b10aec915b3d56ceb1ca62cbc603aa7 | /ecos/dharma/packages/kernel/current/tests/kintr0.c | 14ac21749a41006b8b48b6728b681874bedc4d89 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | eaglexmw-gmail/adotcorporation | 96fd5940c9e8c562570641e3f5e7a10415d83109 | e386b74ab14a34dea09c58d796934293d01c03a9 | refs/heads/master | 2023-03-30T22:49:04.998776 | 2021-03-27T21:08:21 | 2021-03-27T21:08:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 6,931 | c | /*=================================================================
//
// kintr0.c
//
// Kernel C API Intr test 0
//
//==========================================================================
//####COPYRIGHTBEGIN####
//
// -------------------------------------------
// The contents of this file are subject to the Red Hat eCos Public License
// Version 1.1 (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.redhat.com/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations under
// the License.
//
// The Original Code is eCos - Embedded Configurable Operating System,
// released September 30, 1998.
//
// The Initial Developer of the Original Code is Red Hat.
// Portions created by Red Hat are
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
// All Rights Reserved.
// -------------------------------------------
//
//####COPYRIGHTEND####
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): dsm
// Contributors: dsm, jlarmour
// Date: 1999-02-16
// Description: Very basic test of interrupt objects
// Options:
// CYGIMP_KERNEL_INTERRUPTS_DSRS_TABLE
// CYGIMP_KERNEL_INTERRUPTS_DSRS_TABLE_MAX
// CYGIMP_KERNEL_INTERRUPTS_DSRS_LIST
//####DESCRIPTIONEND####
*/
#include <cyg/kernel/kapi.h>
#include <cyg/hal/hal_intr.h>
#include <cyg/infra/testcase.h>
#ifdef CYGFUN_KERNEL_API_C
#include "testaux.h"
static cyg_interrupt intr_obj[2];
static cyg_handle_t intr0, intr1;
static cyg_ISR_t isr0, isr1;
static cyg_DSR_t dsr0, dsr1;
static cyg_uint32 isr0(cyg_vector_t vector, cyg_addrword_t data)
{
CYG_UNUSED_PARAM(cyg_addrword_t, data);
cyg_interrupt_acknowledge(vector);
return 0;
}
static void dsr0(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
CYG_UNUSED_PARAM(cyg_vector_t, vector);
CYG_UNUSED_PARAM(cyg_ucount32, count);
CYG_UNUSED_PARAM(cyg_addrword_t, data);
}
static cyg_uint32 isr1(cyg_vector_t vector, cyg_addrword_t data)
{
CYG_UNUSED_PARAM(cyg_vector_t, vector);
CYG_UNUSED_PARAM(cyg_addrword_t, data);
return 0;
}
static void dsr1(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
CYG_UNUSED_PARAM(cyg_vector_t, vector);
CYG_UNUSED_PARAM(cyg_ucount32, count);
CYG_UNUSED_PARAM(cyg_addrword_t, data);
}
static bool flash( void )
{
cyg_handle_t handle;
cyg_interrupt intr;
cyg_interrupt_create(CYGNUM_HAL_ISR_MIN, 0, (cyg_addrword_t)333,
isr0, dsr0, &handle, &intr );
cyg_interrupt_delete(handle);
return true;
}
/* IMPORTANT: The calling convention for VSRs is target dependent. It is
* unlikely that a plain C or C++ routine would function correctly on any
* particular platform, even if it could correctly access the system
* resources necessary to handle the event that caused it to be called.
* VSRs usually must be written in assembly language.
*
* This is just a test program. The routine vsr0() below is defined simply
* to define an address that will be in executable memory. If an event
* causes this VSR to be called, all bets are off. If it is accidentally
* installed in the vector for the realtime clock, the system will likely
* freeze.
*/
static cyg_VSR_t vsr0;
static void vsr0()
{
}
void kintr0_main( void )
{
cyg_vector_t v = (CYGNUM_HAL_VSR_MIN + 11) % CYGNUM_HAL_VSR_COUNT;
cyg_vector_t v1;
cyg_vector_t lvl1 = (CYGNUM_HAL_ISR_MIN + 1) % (CYGNUM_HAL_ISR_COUNT);
cyg_vector_t lvl2 = (CYGNUM_HAL_ISR_MIN + 15) % (CYGNUM_HAL_ISR_COUNT);
int in_use;
cyg_VSR_t *old_vsr, *new_vsr;
CYG_TEST_INIT();
#ifdef CYGPKG_HAL_MIPS_TX39
// This can be removed when PR 17831 is fixed
if ( cyg_test_is_simulator )
v1 = 12 % CYGNUM_HAL_ISR_COUNT;
else /* NOTE TRAILING ELSE... */
#endif
v1 = (CYGNUM_HAL_ISR_MIN + 6) % CYGNUM_HAL_ISR_COUNT;
CHECK(flash());
CHECK(flash());
// Make sure the chosen levels are not already in use.
HAL_INTERRUPT_IN_USE( lvl1, in_use );
intr0 = 0;
if (!in_use)
cyg_interrupt_create(lvl1, 1, (cyg_addrword_t)777, isr0, dsr0,
&intr0, &intr_obj[0]);
HAL_INTERRUPT_IN_USE( lvl2, in_use );
intr1 = 0;
if (!in_use && lvl1 != lvl2)
cyg_interrupt_create(lvl2, 1, 888, isr1, dsr1, &intr1, &intr_obj[1]);
// Check these functions at least exist
cyg_interrupt_enable();
cyg_interrupt_disable();
if (intr0)
cyg_interrupt_attach(intr0);
if (intr1)
cyg_interrupt_attach(intr1);
if (intr0)
cyg_interrupt_detach(intr0);
if (intr1)
cyg_interrupt_detach(intr1);
// If this attaching interrupt replaces the previous interrupt
// instead of adding to it we could be in a big mess if the
// vector is being used by something important.
cyg_interrupt_get_vsr( v, &old_vsr );
cyg_interrupt_set_vsr( v, vsr0 );
cyg_interrupt_get_vsr( v, &new_vsr );
CHECK( vsr0 == new_vsr );
new_vsr = NULL;
cyg_interrupt_get_vsr( v, &new_vsr );
cyg_interrupt_set_vsr( v, old_vsr );
CHECK( new_vsr == vsr0 );
cyg_interrupt_set_vsr( v, new_vsr );
new_vsr = NULL;
cyg_interrupt_get_vsr( v, &new_vsr );
CHECK( vsr0 == new_vsr );
cyg_interrupt_set_vsr( v, old_vsr );
CHECK( vsr0 == new_vsr );
new_vsr = NULL;
cyg_interrupt_get_vsr( v, &new_vsr );
CHECK( old_vsr == new_vsr );
CHECK( NULL != vsr0 );
cyg_interrupt_mask(v1);
cyg_interrupt_unmask(v1);
cyg_interrupt_configure(v1, true, true);
CYG_TEST_PASS_FINISH("Kernel C API Intr 0 OK");
}
externC void
cyg_start( void )
{
kintr0_main();
}
#else /* def CYGFUN_KERNEL_API_C */
externC void
cyg_start( void )
{
CYG_TEST_INIT();
CYG_TEST_NA("Kernel C API layer disabled");
}
#endif /* def CYGFUN_KERNEL_API_C */
/* EOF kintr0.c */
| [
"pleasemarkdarkly@gmail.com"
] | pleasemarkdarkly@gmail.com |
9ed52034fbf0b2401303361dc5ff84d05fd9c2d3 | e43fba76f1e2445dcfce2daa2015844a3d9158d6 | /code.c | 9666b914c17400867d39e4a0b98fe4c96467921c | [] | no_license | SILVERORONE/1laba | 827fd31d1c7e1b2759bd4d22fa31fec1ec6d2341 | 58e8323325b23cf1f554516fe4584711a01b4503 | refs/heads/main | 2023-08-18T20:57:45.246880 | 2021-10-14T11:03:47 | 2021-10-14T11:03:47 | 417,096,053 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,398 | c | #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <locale.h>
int main() {
setlocale(LC_ALL, "Rus");
unsigned short int n = 0;
unsigned short int min = 0;
unsigned short int max = 0;
float number = 0;
int qw = 0;
float qe = 0;
int qr = 0;
float sum = 0;
int j = 0;
//float otvet = 0;
printf("Введите колличество чисел: ");
scanf_s("%hu", &n);
printf("Введите минимальное значение : ");
scanf_s("%hu", &min);
printf("Введите максимальное значение : ");
scanf_s("%hu", &max);
for (int i = 0; i < n; i++) {
if (n < 10) {
number = (float)rand() / RAND_MAX * (max - min) + min;
printf("Число : ");
printf("%f \n", number);
qw = number;
qe = number - qw;
qr = qe * 10;
printf("qr: ");
printf("%d \n", qr);
}
else {
number = (float)rand() / RAND_MAX * (max - min) + min;
printf("Число : ");
printf("%f \n", number);
qw = number;
qe = number - qw;
qr = qe * 100;
printf("qr: ");
printf("%d \n", qr);
}
j = 0;
while (j <= n ) {
if(qr < n) {
sum = sum - number;
printf("Вычли : ");
printf("%f \n", sum);
break;
}
else {
sum = sum + number;
printf("Сложили : ");
printf("%f \n", sum);
break;
}
j++;
}
}
printf("%f", sum);
return 0;
}
| [
"noreply@github.com"
] | SILVERORONE.noreply@github.com |
8be4e329d89106b6f065118119de0274edd23632 | 57339502c199b4a90cbefafb70a98e0e67992af3 | /nextFitAllocatorTester.c | 79f7892c7ebc5871679aa633af1e3dbc09043c76 | [
"BSD-3-Clause"
] | permissive | 2017-fall-os/2017-fall-malloc-lab-Sebezayala | 028881ac5834ebb873c8615491b276dd6669a93a | df9b28c90bb5e38339d83411bb0c974738d26ee1 | refs/heads/master | 2021-07-21T05:28:09.526020 | 2017-10-30T06:28:08 | 2017-10-30T06:28:08 | 105,904,807 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,702 | c | #include "stdio.h"
#include "stdlib.h"
#include "myAllocator.h"
#include "sys/time.h"
#include <sys/resource.h>
#include <unistd.h>
double diffTimeval(struct timeval *t1, struct timeval *t2) {
double d = (t1->tv_sec - t2->tv_sec) + (1.0e-6 * (t1->tv_usec - t2->tv_usec));
return d;
}
void getutime(struct timeval *t)
{
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
*t = usage.ru_utime;
}
int main()
{
void *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10;
arenaCheck();
p1 = nextFitAllocRegion(254000);
p2 = nextFitAllocRegion(40000);
p3 = nextFitAllocRegion(158000);
p4 = nextFitAllocRegion(18000);
p5 = nextFitAllocRegion(100000);
p6 = nextFitAllocRegion(8000);
p7 = nextFitAllocRegion(300000);
p8 = nextFitAllocRegion(1000);
p9 = nextFitAllocRegion(3000);
p10 = nextFitAllocRegion(60000);
freeRegion(p2);
freeRegion(p3);
freeRegion(p5);
freeRegion(p7);
freeRegion(p9);
arenaCheck();
p2 = nextFitAllocRegion(50000);
arenaCheck();
p3 = nextFitAllocRegion(70000);
arenaCheck();
p5 = nextFitAllocRegion(40000);
arenaCheck();
p7 = nextFitAllocRegion(105000);
arenaCheck();
p9 = nextFitAllocRegion(5000);
arenaCheck();
freeRegion(p1);
freeRegion(p4);
freeRegion(p6);
freeRegion(p8);
freeRegion(p10);
freeRegion(p2);
freeRegion(p3);
freeRegion(p5);
freeRegion(p7);
freeRegion(p9);
arenaCheck();
{ /* measure time for 10000 mallocs */
struct timeval t1, t2;
int i;
getutime(&t1);
for(i = 0; i < 10000; i++)
if (nextFitAllocRegion(4) == 0)
break;
getutime(&t2);
printf("%d nextFitAllocRegion(4) required %f seconds\n", i, diffTimeval(&t2, &t1));
}
return 0;
}
| [
"Sayalaurtaza@miners.utep.edu"
] | Sayalaurtaza@miners.utep.edu |
ff8691a883bf7ef42b1a32c67c76018e8360094a | d43f27406aef0dd3dc09c1b8ec13dc1659210bee | /剑指Offer/二维数组中查找/code/C/search_in_matrix.c | cfebf05961262744c7aa5ac3a55ead6dc13cbc07 | [
"Apache-2.0"
] | permissive | victory20201009/BookReadingMarkdown | 14ee0c7bfb5c8c80cced02e5398c455b325cc70c | 37cfaa44108c467503569afa0430154b5071eea4 | refs/heads/master | 2022-11-06T15:37:20.505068 | 2020-06-21T09:01:57 | 2020-06-21T09:01:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,060 | c | #include<stdio.h>
//查找函数,存在返回1,否则返回0
int search_in_matrix(int* matrix, int rows, int columns, int target) {
int res = 0, t;
if (matrix != NULL) {
int row = 0, column = columns - 1;
while (row<rows && column>-1) {
t = matrix[columns * row + column];
printf("t:%d,row=%d,column=%d\n",t,row,column);
if (t == target) {//等于直接返回
res = 1;
break;
}
else if (target > t)++row;//大于当前元素,舍弃当前行,移到下一行
else --column;//小于当前元素,舍弃当前列,往前移动一列
}
}
return res;
}
void run_search(int* matrix, int rows, int columns, int target) {
printf("target=%d\n", target);
if (search_in_matrix(matrix, rows, columns, target))
printf("%d in arr\n", target);
else printf("%d not in arr\n", target);
}
int main() {
int target = 5;
int* arr1 = NULL;
int arr2[] = { 1 };
int arr3[] = {
1,2,3,4,5,
2,3,4,7,9,
4,5,9,10,12
};
//run_search(arr1, 1, 1, target);
//run_search(arr2, 1, 1, 1);
run_search(arr3, 3, 5, 7);
return 0;
}
| [
"1810826525@qq.com"
] | 1810826525@qq.com |
2dee3c1aaec36ee5b4417d3314ce2b672a64650b | 3b418f960953b13fb194460f024452d2c77544d5 | /huffman_encode_image.c | ba24c9be59e6f64d6bde72c1f3db5a3ebc4b8aa1 | [] | no_license | McMastS/4481-2 | dfa066e31ff9c05fcfa729e30b31195bf2419a41 | ee0ceb884976767c3d34add000d3000c4174c115 | refs/heads/master | 2021-01-16T11:50:24.546057 | 2020-02-25T21:42:27 | 2020-02-25T21:42:27 | 243,108,319 | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 7,611 | c | #include "huffman_encode_image.h"
#include "generate_pixel_frequency.h"
#define MAX_CODE_LENGTH 16
void print_binary(int number)
{
if (number == 0) printf("0");
if (number) {
print_binary(number >> 1);
putc((number & 1) ? '1' : '0', stdout);
}
}
void free_huffman_codes(char **codes, int length)
{
for(int i = 0; i < length; i++)
free(codes[i]);
free(codes);
}
// https://stackoverflow.com/questions/14176123/correct-usage-of-strtol
bool parse_long(const char *str, long *val)
{
char *temp;
bool rc = true;
*val = strtol(str, &temp, 2); // radix must be 2, as string is in binary representation
if (temp == str || *temp != '\0') rc = false;
return rc;
}
unsigned char *huffman_encode_image(struct PGM_Image *input_pgm_image, struct node *huffman_node, int number_of_nodes, long int *length_of_encoded_image_array)
{
char **huffman_codes = malloc((input_pgm_image->maxGrayValue + 1) * sizeof(char *));
if (huffman_codes == NULL)
{
printf("Allocating huffman codes went wrong.\n");
exit(0);
}
for (int i = 0; i < input_pgm_image->maxGrayValue + 1; i++)
{
huffman_codes[i] = (char *)malloc(MAX_CODE_LENGTH + 1);
if (huffman_codes[i] == NULL)
{
printf("Allocating strings in huffman codes went wrong.\n");
exit(0);
}
strcpy(huffman_codes[i], "");
}
for (int i = number_of_nodes - 1; i >= 0; i--)
{
struct node curr_node = huffman_node[i];
if (i == number_of_nodes - 1)
{
strcpy(huffman_codes[curr_node.first_value], "0");
strcpy(huffman_codes[curr_node.second_value], "1");
}
else
{
const char *first_val = huffman_codes[curr_node.first_value];
const char *second_val = huffman_codes[curr_node.second_value];
if (first_val[0] == '\0')
{
strcpy(huffman_codes[curr_node.first_value], second_val);
strcat(huffman_codes[curr_node.first_value], "0");
strcat(huffman_codes[curr_node.second_value], "1");
}
else if (second_val[0] == '\0')
{
strcpy(huffman_codes[curr_node.second_value], first_val);
strcat(huffman_codes[curr_node.first_value], "0");
strcat(huffman_codes[curr_node.second_value], "1");
}
}
}
for (int i = 0; i < 255+1; i++)
{
if (*huffman_codes[i] != '\0') printf("Code for %d = %s \n", i, huffman_codes[i]);
}
// for the size, you have the frequency array and the bit size for each, so you can find the byte length that way
// Start with a size of 100
long int allocated_len = 100;
unsigned char *encoded_image = malloc(allocated_len * sizeof(unsigned char));
if (encoded_image == NULL)
{
printf("Memory for encoded image was not allocated.\n");
exit(0);
}
int curr_bits_allocated = 0;
char *curr_byte = malloc(9); // 8 bits + \0 char
for (int row = 0; row < input_pgm_image->height; row++)
{
for (int col = 0; col < input_pgm_image->width; col++)
{
int symbol = input_pgm_image->image[row][col];
const char *code = huffman_codes[symbol];
int code_length = strlen(code);
if (curr_bits_allocated + code_length > 8) // byte would overflow
{
// printf("overflow\n");
int code_remainder = (curr_bits_allocated + code_length) - 8; // bits left in code
int byte_remainder = code_length - code_remainder; // bits left in byte
// figure out logic
for (int i = 8 - byte_remainder, j = 0; i < 8; i++, j++) // probably wrong
{
curr_byte[i] = code[j];
// strcat(curr_byte, code[j]); // might have to do strcpy?
}
// throw in function if time allows
unsigned char temp_char;
char *temp;
long val = strtol(curr_byte, &temp, 2);
temp_char = (unsigned char) val;
if (*length_of_encoded_image_array + 10 > allocated_len)
{
allocated_len *= 2;
unsigned char *realloacted = realloc(encoded_image, allocated_len);
if (realloacted == NULL)
{
printf("Couldn't reallocate encoded image array.");
exit(0);
}
encoded_image = realloacted;
}
encoded_image[*length_of_encoded_image_array] = temp_char;
(*length_of_encoded_image_array)++;
curr_bits_allocated = 0;
strcpy(curr_byte, "");
for (int i = 0, j = code_length - code_remainder; j < code_remainder; i++, j++)
{
curr_byte[i] = code[j];
// strcat(curr_byte, to_add);
}
}
else if (curr_bits_allocated + code_length == 8) // byte is full, but not overflowing
{
strcat(curr_byte, code);
unsigned char temp_char;
char *temp;
long val = strtol(curr_byte, &temp, 2);
temp_char = (unsigned char) val;
if (*length_of_encoded_image_array + 10 > allocated_len)
{
allocated_len *= 2;
unsigned char *realloacted = realloc(encoded_image, allocated_len);
if (realloacted == NULL)
{
printf("Couldn't reallocate encoded image array.");
exit(0);
}
encoded_image = realloacted;
}
encoded_image[*length_of_encoded_image_array] = temp_char;
(*length_of_encoded_image_array)++;
curr_bits_allocated = 0;
strcpy(curr_byte, "");
}
else // regular case
{
strcat(curr_byte, code);
curr_bits_allocated += code_length;
}
}
}
free_huffman_codes(huffman_codes, input_pgm_image->maxGrayValue+1);
return encoded_image;
}
int main(int argc, const char* argv[])
{
struct PGM_Image pic;
if (load_PGM_Image(&pic, "test_square.raw.pgm") == -1)
{
printf("Something went wrong loading the image.\n");
return -1;
}
int non_zero_freq = 0;
long int *pixel_freq = generate_pixel_frequency(&pic, &non_zero_freq);
struct node *huff_nodes = generate_huffman_nodes(pixel_freq, pic.maxGrayValue, non_zero_freq);
long int image_size = 0;
unsigned char *encoded_image = huffman_encode_image(&pic, huff_nodes, non_zero_freq - 1, &image_size);
printf("size: %ld\n", image_size);
printf("Last 10 for encoded: \n");
for (int i = image_size - 1; i > image_size - 10; i--){
printf("%u", encoded_image[i]);
printf(" \n");
}
free(huff_nodes);
free(pixel_freq);
free(encoded_image);
free_PGM_Image(&pic);
} | [
"spencerm133@gmail.com"
] | spencerm133@gmail.com |
5ca8ac2b2442d507d64ee61ecdac2985e4a9f8f0 | 96db7bfad07f22dc62701736817b859c921465ca | /Big Number/teste.c | 594341c3f01921c6f4f58dfd42cf9ddfa2941f56 | [] | no_license | LinsThi/ed_UFC | 9a64573133fa847c35081b3b440bc274f16b73d5 | b2269fade01ad8d102f657cfc27a297aba4b8da4 | refs/heads/master | 2023-05-07T19:01:00.295789 | 2021-05-31T16:34:30 | 2021-05-31T16:34:30 | 372,568,267 | 3 | 0 | null | null | null | null | UTF-8 | C | false | false | 1,268 | c | #include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef struct estr
{
int valor;
struct estr *prox;
} NO;
//Recebe um vetor de inteiros e devolve uma lista ligada de nos
NO* deVetorParaLista(int *v, int t)
{
int i;
NO* p = NULL;
NO* a = NULL;//endereco do no anterior
NO* lista = NULL;
for(i = 0; i < t; i++ )
{
p = (NO*)malloc(sizeof(NO));
p->valor = v[i];
p->prox = NULL;
if(i==0)
{
//copia primeiro endereco para variavel a ser retornada
lista=p;
}else{
//se nao for o primeiro elemento copia endereco para 'prox' do no anterior
a->prox=p;
}
a=p;
}
return lista;
}
void imprimir(NO *p)
{
printf("\n");
while(p!=NULL)
{
printf("%d",p->valor);
printf("\n");
p=p->prox;
}
}
//libera memoria alocada
void limparLista(NO *p)
{
NO *n;
while(p!=NULL)
{
n=p->prox;
free(p);
p=n;
}
}
int main()
{
int v[] = {5,17,-2,55,1000};
int t = (sizeof(v))/sizeof(int); //tamanho do vetor v
NO* p=deVetorParaLista(v, t);
imprimir(p);
//limpar lista(somente depois de usa-la)
limparLista(p);
return 0;
} | [
"thiagolins13255@gmail.com"
] | thiagolins13255@gmail.com |
666103ee493ed8c1e19b7badac128a5d24ae3f2f | 57bc404899f914eeef7ba298bf1e99883c864a26 | /_other_languages/c_language/dynamic_connectivity/quick_find/quick_find.c | bbf67c58a2d2d893fa818b85165a3909f8a033db | [
"MIT"
] | permissive | priyankchheda/algorithms | 547f19193273ac6a424fe4ba5e1375cc02ea4f60 | 38a5de72db14ef2664489da9857b598d24c4e276 | refs/heads/master | 2023-08-17T17:10:10.044940 | 2022-04-16T13:52:37 | 2022-04-16T13:52:37 | 133,684,565 | 195 | 38 | MIT | 2023-08-16T10:26:48 | 2018-05-16T15:10:56 | C++ | UTF-8 | C | false | false | 493 | c | #include <stdlib.h>
#include "quick_find.h"
int *
initialize(int n)
{
int *array = (int*) malloc(sizeof(int) * n);
for (int i = 0; i < n; i++)
array[i] = i;
return array;
}
void
join_union(int *arr, int n, int p, int q)
{
int pid = arr[p];
int qid = arr[q];
for (int i = 0; i < n; i++)
if (arr[i] == pid)
arr[i] = qid;
}
int
connected(int* arr, int p, int q)
{
return arr[p] == arr[q];
}
void
terminate(int* arr)
{
free(arr);
}
| [
"p.chheda29@gmail.com"
] | p.chheda29@gmail.com |
fc0186960bd6806541a8dd806522af7079e00193 | 885242cc4da3cfe85671d497d56e0795f1155024 | /final/code_flight/husOBC/husOBC/hSlave_Master+CCtest/common.h | 1734a9e7c95329b7b6899f726a7571b19f13e0a7 | [] | no_license | singhalanirudh18/Advitiy | 04bc38352f7a0bde29706521155764f7b7534df0 | ec99309d8b44a9d97f246e4137bfdf9b37b57715 | refs/heads/master | 2021-08-29T17:12:15.252675 | 2017-12-14T12:00:52 | 2017-12-14T12:00:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 3,090 | h | /*
* common.h
*
* Created: 31-03-2012 14:40:20
* Author: Hussain
*/
/**
*@file common.h
*@brief Contains the various constant/macro/struct definitions, clock frequency and general functions
* for SLAVE
*/
#ifndef COMMON_H_
#define COMMON_H_
///CPU frequency
#define F_CPU 8000000
#define NULL 0
#include <math.h>
#include <avr/io.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>
#define sbi(x,y) (x |= (1<<y))
#define cbi(x,y) (x &= ~(1<<y))
#define tbi(x,y) (x ^= (1<<y))
//#define TRUE 1
//#define FALSE 0
/**
* @defgroup Modes
* @brief Modes of operation of satellite
* @todo Safe and emergency mode details to be obtained and coded
*/
//@{
/// During preflight checks
#define PREFLIGHT 0
/// Normal Mode
#define NOMINAL 1
/// Low power Mode
#define SAFE 2
/// Failure Mode
#define EMERGENCY 3
/// Detumbling Mode
#define DETUMBLING 4
//@}
/**
*@defgroup Preflight_check
*@todo Check port and pin for preflight checks
*/
//@{
///Port for preflight checks
#define DDR_PF DDRA
#define PORT_PF PINA
/// Pin to check for preflight checks mode
#define PIN_PF PA0
//@}
#define LOCK PE6 // Connected to LOCK pin of CC1020
#define DIO PE5 // Connected to DIO pin of CC1020
#define DCLK PE4 // Connected to DCLK pin of CC1020
#define DDR_TRX DDRE
#define PORT_TRX PORTE
#define PIN_TRX PINE
#define DDR_PA DDRE
#define PORT_PA PORTE
#define PIN_PA PINE
#define PA_EN PE7 // Connected to PA enable TPS
/**
* @defgroup TX_region Transmission Regions
* @brief Defining centre and radius for communication check
*/
//@{
#define IN_LAT 22.5833
#define IN_LON 82.7666
#define IN_RAD 15
#define FR_LAT 48.861101
#define FR_LON 2.352104
#define FR_RAD 6
#define GS_LAT 19.133167
#define GS_LON 72.915144
#define GS_RAD 6
#define IN 1
#define GS 2
#define FR 3
//@}
///Frame Time for the main loop
#define FRAME_TIME 2
#define EEP_FRAME_SIZE 22
static uint32_t read_addr = 0, write_addr = 0;
/************************************************************************/
/************************************************************************/
#define rf_lock1 'w'
#define rf_lock2 'x'
#define RESET 0
#define OVER 52 //104 bytes in the buffer
enum boolean { FALSE=0, TRUE=1 };
enum boolean new_packet_received, data_ack_received, t1_overflow,
t1_active, t4_overflow, t4_active;
short packet_ready;
unsigned char dummy, rf_key1, rf_key2;
unsigned char rx_buf[70] ;
volatile char TXBUFFER[20];
volatile char RXBUFFER[20];
int curr_buffer_index, curr_byte;
int no_bytes_tosend; // Total no. of bytes to be transmitted
int no_databytes_toread; // No. of Data bytes to read after SOF2 and no. of bytes.
int rxcount; // Total no. of bits received
/************************************************************************/
/************************************************************************/
#endif /* COMMON_H_ */ | [
"singhalanirudh18@gmail.com"
] | singhalanirudh18@gmail.com |
7a9bbe9f107122c88ed19360060effbdc67aa541 | c2cedcf36667730f558ab354bea4505b616c90d2 | /players/francesco/roma/rooms/vi32.c | 6112f5963552a80e7c5a57fbbdb1030a607926e3 | [] | no_license | wugouzi/Nirvlp312mudlib | 965ed876c7080ab00e28c5d8cd5ea9fc9e46258f | 616cad7472279cc97c9693f893940f5336916ff8 | refs/heads/master | 2023-03-16T03:45:05.510851 | 2017-09-21T17:05:00 | 2017-09-21T17:05:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C | false | false | 475 | c | #include "/players/francesco/univ/ansi.h"
#define tp this_player()
#define tpn this_player()->query_name()
#define tpp this_player()->query_possessive()
inherit "room/room";
reset(arg) {
if(arg) return;
set_light(1);
short_desc = "New area, under construction" ;
long_desc =
" via32\n",
items = ({
});
dest_dir = ({
"/players/francesco/roma/rooms/vi31.c","south",
"/players/francesco/roma/rooms/vi33.c","north"
});
}
init(){
::init();
}
| [
"rump.nirv@gmail.com"
] | rump.nirv@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.