This commit is contained in:
David Rose 2016-05-13 18:21:53 -07:00
commit d73d02fc27
255 changed files with 8354 additions and 7541 deletions

View File

@ -1550,7 +1550,7 @@ YY_RULE_SETUP
dcyylval.u.uint64 = 0;
const char *p = dcyytext;
while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 10;
uint64_t next_value = dcyylval.u.uint64 * 10;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;
@ -1583,9 +1583,9 @@ YY_RULE_SETUP
++p;
}
PN_uint64 value = 0;
uint64_t value = 0;
while (*p != '\0') {
PN_uint64 next_value = value * 10;
uint64_t next_value = value * 10;
if (next_value < value) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
@ -1597,13 +1597,13 @@ YY_RULE_SETUP
}
if (neg) {
dcyylval.u.int64 = -(PN_int64)value;
dcyylval.u.int64 = -(int64_t)value;
if (dcyylval.u.int64 > 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
}
} else {
dcyylval.u.int64 = (PN_int64)value;
dcyylval.u.int64 = (int64_t)value;
if (dcyylval.u.int64 < 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
@ -1625,7 +1625,7 @@ YY_RULE_SETUP
dcyylval.u.uint64 = 0;
const char *p = dcyytext + 2;
while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 16;
uint64_t next_value = dcyylval.u.uint64 * 16;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;

View File

@ -612,7 +612,7 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
dcyylval.u.uint64 = 0;
const char *p = dcyytext;
while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 10;
uint64_t next_value = dcyylval.u.uint64 * 10;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;
@ -642,9 +642,9 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
++p;
}
PN_uint64 value = 0;
uint64_t value = 0;
while (*p != '\0') {
PN_uint64 next_value = value * 10;
uint64_t next_value = value * 10;
if (next_value < value) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
@ -656,13 +656,13 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
}
if (neg) {
dcyylval.u.int64 = -(PN_int64)value;
dcyylval.u.int64 = -(int64_t)value;
if (dcyylval.u.int64 > 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
}
} else {
dcyylval.u.int64 = (PN_int64)value;
dcyylval.u.int64 = (int64_t)value;
if (dcyylval.u.int64 < 0) {
dcyyerror("Number out of range.");
dcyylval.u.int64 = 1;
@ -681,7 +681,7 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
dcyylval.u.uint64 = 0;
const char *p = dcyytext + 2;
while (*p != '\0') {
PN_uint64 next_value = dcyylval.u.uint64 * 16;
uint64_t next_value = dcyylval.u.uint64 * 16;
if (next_value < dcyylval.u.uint64) {
dcyyerror("Number out of range.");
dcyylval.u.uint64 = 1;

View File

@ -71,8 +71,8 @@ private:
typedef DCNumericRange<int> DCIntRange;
typedef DCNumericRange<unsigned int> DCUnsignedIntRange;
typedef DCNumericRange<PN_int64> DCInt64Range;
typedef DCNumericRange<PN_uint64> DCUnsignedInt64Range;
typedef DCNumericRange<int64_t> DCInt64Range;
typedef DCNumericRange<uint64_t> DCUnsignedInt64Range;
typedef DCNumericRange<double> DCDoubleRange;
#endif

View File

@ -178,7 +178,7 @@ pack_uint(unsigned int value) {
* Packs the indicated numeric or string value into the stream.
*/
INLINE void DCPacker::
pack_int64(PN_int64 value) {
pack_int64(int64_t value) {
nassertv(_mode == M_pack || _mode == M_repack);
if (_current_field == NULL) {
_pack_error = true;
@ -192,7 +192,7 @@ pack_int64(PN_int64 value) {
* Packs the indicated numeric or string value into the stream.
*/
INLINE void DCPacker::
pack_uint64(PN_uint64 value) {
pack_uint64(uint64_t value) {
nassertv(_mode == M_pack || _mode == M_repack);
if (_current_field == NULL) {
_pack_error = true;
@ -291,9 +291,9 @@ unpack_uint() {
/**
* Unpacks the current numeric or string value from the stream.
*/
INLINE PN_int64 DCPacker::
INLINE int64_t DCPacker::
unpack_int64() {
PN_int64 value = 0;
int64_t value = 0;
nassertr(_mode == M_unpack, value);
if (_current_field == NULL) {
_pack_error = true;
@ -310,9 +310,9 @@ unpack_int64() {
/**
* Unpacks the current numeric or string value from the stream.
*/
INLINE PN_uint64 DCPacker::
INLINE uint64_t DCPacker::
unpack_uint64() {
PN_uint64 value = 0;
uint64_t value = 0;
nassertr(_mode == M_unpack, value);
if (_current_field == NULL) {
_pack_error = true;
@ -409,7 +409,7 @@ unpack_uint(unsigned int &value) {
* Unpacks the current numeric or string value from the stream.
*/
INLINE void DCPacker::
unpack_int64(PN_int64 &value) {
unpack_int64(int64_t &value) {
nassertv(_mode == M_unpack);
if (_current_field == NULL) {
_pack_error = true;
@ -425,7 +425,7 @@ unpack_int64(PN_int64 &value) {
* Unpacks the current numeric or string value from the stream.
*/
INLINE void DCPacker::
unpack_uint64(PN_uint64 &value) {
unpack_uint64(uint64_t &value) {
nassertv(_mode == M_unpack);
if (_current_field == NULL) {
_pack_error = true;
@ -668,7 +668,7 @@ raw_pack_int32(int value) {
* Packs the data into the buffer between packing sessions.
*/
INLINE void DCPacker::
raw_pack_int64(PN_int64 value) {
raw_pack_int64(int64_t value) {
nassertv(_mode == M_idle);
DCPackerInterface::do_pack_int64(_pack_data.get_write_pointer(8), value);
}
@ -704,7 +704,7 @@ raw_pack_uint32(unsigned int value) {
* Packs the data into the buffer between packing sessions.
*/
INLINE void DCPacker::
raw_pack_uint64(PN_uint64 value) {
raw_pack_uint64(uint64_t value) {
nassertv(_mode == M_idle);
DCPackerInterface::do_pack_uint64(_pack_data.get_write_pointer(8), value);
}
@ -761,9 +761,9 @@ raw_unpack_int32() {
/**
* Unpacks the data from the buffer between unpacking sessions.
*/
INLINE PN_int64 DCPacker::
INLINE int64_t DCPacker::
raw_unpack_int64() {
PN_int64 value = 0;
int64_t value = 0;
raw_unpack_int64(value);
return value;
}
@ -843,9 +843,9 @@ raw_unpack_uint32() {
/**
* Unpacks the data from the buffer between unpacking sessions.
*/
INLINE PN_uint64 DCPacker::
INLINE uint64_t DCPacker::
raw_unpack_uint64() {
PN_uint64 value = 0;
uint64_t value = 0;
raw_unpack_uint64(value);
return value;
}
@ -874,7 +874,7 @@ raw_unpack_string() {
* Unpacks the data from the buffer between unpacking sessions.
*/
INLINE void DCPacker::
raw_unpack_int64(PN_int64 &value) {
raw_unpack_int64(int64_t &value) {
nassertv(_mode == M_idle && _unpack_data != NULL);
if (_unpack_p + 8 > _unpack_length) {
_pack_error = true;
@ -930,7 +930,7 @@ raw_unpack_uint32(unsigned int &value) {
* Unpacks the data from the buffer between unpacking sessions.
*/
INLINE void DCPacker::
raw_unpack_uint64(PN_uint64 &value) {
raw_unpack_uint64(uint64_t &value) {
nassertv(_mode == M_idle && _unpack_data != NULL);
if (_unpack_p + 8 > _unpack_length) {
_pack_error = true;

View File

@ -858,14 +858,14 @@ unpack_object() {
case PT_int64:
{
PN_int64 value = unpack_int64();
int64_t value = unpack_int64();
object = PyLong_FromLongLong(value);
}
break;
case PT_uint64:
{
PN_uint64 value = unpack_uint64();
uint64_t value = unpack_uint64();
object = PyLong_FromUnsignedLongLong(value);
}
break;

View File

@ -72,8 +72,8 @@ PUBLISHED:
INLINE void pack_double(double value);
INLINE void pack_int(int value);
INLINE void pack_uint(unsigned int value);
INLINE void pack_int64(PN_int64 value);
INLINE void pack_uint64(PN_uint64 value);
INLINE void pack_int64(int64_t value);
INLINE void pack_uint64(uint64_t value);
INLINE void pack_string(const string &value);
INLINE void pack_literal_value(const string &value);
void pack_default_value();
@ -81,8 +81,8 @@ PUBLISHED:
INLINE double unpack_double();
INLINE int unpack_int();
INLINE unsigned int unpack_uint();
INLINE PN_int64 unpack_int64();
INLINE PN_uint64 unpack_uint64();
INLINE int64_t unpack_int64();
INLINE uint64_t unpack_uint64();
INLINE string unpack_string();
INLINE string unpack_literal_value();
void unpack_validate();
@ -94,8 +94,8 @@ public:
INLINE void unpack_double(double &value);
INLINE void unpack_int(int &value);
INLINE void unpack_uint(unsigned int &value);
INLINE void unpack_int64(PN_int64 &value);
INLINE void unpack_uint64(PN_uint64 &value);
INLINE void unpack_int64(int64_t &value);
INLINE void unpack_uint64(uint64_t &value);
INLINE void unpack_string(string &value);
INLINE void unpack_literal_value(string &value);
@ -141,11 +141,11 @@ PUBLISHED:
INLINE void raw_pack_int8(int value);
INLINE void raw_pack_int16(int value);
INLINE void raw_pack_int32(int value);
INLINE void raw_pack_int64(PN_int64 value);
INLINE void raw_pack_int64(int64_t value);
INLINE void raw_pack_uint8(unsigned int value);
INLINE void raw_pack_uint16(unsigned int value);
INLINE void raw_pack_uint32(unsigned int value);
INLINE void raw_pack_uint64(PN_uint64 value);
INLINE void raw_pack_uint64(uint64_t value);
INLINE void raw_pack_float64(double value);
INLINE void raw_pack_string(const string &value);
@ -158,11 +158,11 @@ PUBLISHED:
INLINE int raw_unpack_int8();
INLINE int raw_unpack_int16();
INLINE int raw_unpack_int32();
INLINE PN_int64 raw_unpack_int64();
INLINE int64_t raw_unpack_int64();
INLINE unsigned int raw_unpack_uint8();
INLINE unsigned int raw_unpack_uint16();
INLINE unsigned int raw_unpack_uint32();
INLINE PN_uint64 raw_unpack_uint64();
INLINE uint64_t raw_unpack_uint64();
INLINE double raw_unpack_float64();
INLINE string raw_unpack_string();
@ -170,11 +170,11 @@ public:
INLINE void raw_unpack_int8(int &value);
INLINE void raw_unpack_int16(int &value);
INLINE void raw_unpack_int32(int &value);
INLINE void raw_unpack_int64(PN_int64 &value);
INLINE void raw_unpack_int64(int64_t &value);
INLINE void raw_unpack_uint8(unsigned int &value);
INLINE void raw_unpack_uint16(unsigned int &value);
INLINE void raw_unpack_uint32(unsigned int &value);
INLINE void raw_unpack_uint64(PN_uint64 &value);
INLINE void raw_unpack_uint64(uint64_t &value);
INLINE void raw_unpack_float64(double &value);
INLINE void raw_unpack_string(string &value);

View File

@ -142,7 +142,7 @@ do_pack_int32(char *buffer, int value) {
*
*/
INLINE void DCPackerInterface::
do_pack_int64(char *buffer, PN_int64 value) {
do_pack_int64(char *buffer, int64_t value) {
buffer[0] = (char)(value & 0xff);
buffer[1] = (char)((value >> 8) & 0xff);
buffer[2] = (char)((value >> 16) & 0xff);
@ -185,7 +185,7 @@ do_pack_uint32(char *buffer, unsigned int value) {
*
*/
INLINE void DCPackerInterface::
do_pack_uint64(char *buffer, PN_uint64 value) {
do_pack_uint64(char *buffer, uint64_t value) {
buffer[0] = (char)(value & 0xff);
buffer[1] = (char)((value >> 8) & 0xff);
buffer[2] = (char)((value >> 16) & 0xff);
@ -244,16 +244,16 @@ do_unpack_int32(const char *buffer) {
/**
*
*/
INLINE PN_int64 DCPackerInterface::
INLINE int64_t DCPackerInterface::
do_unpack_int64(const char *buffer) {
return (PN_int64)((PN_uint64)(unsigned char)buffer[0] |
((PN_uint64)(unsigned char)buffer[1] << 8) |
((PN_uint64)(unsigned char)buffer[2] << 16) |
((PN_uint64)(unsigned char)buffer[3] << 24) |
((PN_uint64)(unsigned char)buffer[4] << 32) |
((PN_uint64)(unsigned char)buffer[5] << 40) |
((PN_uint64)(unsigned char)buffer[6] << 48) |
((PN_int64)(signed char)buffer[7] << 54));
return (int64_t)((uint64_t)(unsigned char)buffer[0] |
((uint64_t)(unsigned char)buffer[1] << 8) |
((uint64_t)(unsigned char)buffer[2] << 16) |
((uint64_t)(unsigned char)buffer[3] << 24) |
((uint64_t)(unsigned char)buffer[4] << 32) |
((uint64_t)(unsigned char)buffer[5] << 40) |
((uint64_t)(unsigned char)buffer[6] << 48) |
((int64_t)(signed char)buffer[7] << 54));
}
/**
*
@ -286,16 +286,16 @@ do_unpack_uint32(const char *buffer) {
/**
*
*/
INLINE PN_uint64 DCPackerInterface::
INLINE uint64_t DCPackerInterface::
do_unpack_uint64(const char *buffer) {
return ((PN_uint64)(unsigned char)buffer[0] |
((PN_uint64)(unsigned char)buffer[1] << 8) |
((PN_uint64)(unsigned char)buffer[2] << 16) |
((PN_uint64)(unsigned char)buffer[3] << 24) |
((PN_uint64)(unsigned char)buffer[4] << 32) |
((PN_uint64)(unsigned char)buffer[5] << 40) |
((PN_uint64)(unsigned char)buffer[6] << 48) |
((PN_int64)(signed char)buffer[7] << 54));
return ((uint64_t)(unsigned char)buffer[0] |
((uint64_t)(unsigned char)buffer[1] << 8) |
((uint64_t)(unsigned char)buffer[2] << 16) |
((uint64_t)(unsigned char)buffer[3] << 24) |
((uint64_t)(unsigned char)buffer[4] << 32) |
((uint64_t)(unsigned char)buffer[5] << 40) |
((uint64_t)(unsigned char)buffer[6] << 48) |
((int64_t)(signed char)buffer[7] << 54));
}
@ -342,8 +342,8 @@ validate_int_limits(int value, int num_bits, bool &range_error) {
* true if it does not.
*/
INLINE void DCPackerInterface::
validate_int64_limits(PN_int64 value, int num_bits, bool &range_error) {
PN_int64 mask = ((PN_int64)1 << (num_bits - 1)) - 1;
validate_int64_limits(int64_t value, int num_bits, bool &range_error) {
int64_t mask = ((int64_t)1 << (num_bits - 1)) - 1;
value |= mask;
if (value != mask && value != -1) {
@ -373,8 +373,8 @@ validate_uint_limits(unsigned int value, int num_bits, bool &range_error) {
* range_error true if it does not.
*/
INLINE void DCPackerInterface::
validate_uint64_limits(PN_uint64 value, int num_bits, bool &range_error) {
PN_uint64 mask = ((PN_uint64)1 << num_bits) - 1;
validate_uint64_limits(uint64_t value, int num_bits, bool &range_error) {
uint64_t mask = ((uint64_t)1 << num_bits) - 1;
value &= ~mask;
if (value != 0) {

View File

@ -226,7 +226,7 @@ pack_uint(DCPackData &, unsigned int, bool &pack_error, bool &) const {
* Packs the indicated numeric or string value into the stream.
*/
void DCPackerInterface::
pack_int64(DCPackData &, PN_int64, bool &pack_error, bool &) const {
pack_int64(DCPackData &, int64_t, bool &pack_error, bool &) const {
pack_error = true;
}
@ -234,7 +234,7 @@ pack_int64(DCPackData &, PN_int64, bool &pack_error, bool &) const {
* Packs the indicated numeric or string value into the stream.
*/
void DCPackerInterface::
pack_uint64(DCPackData &, PN_uint64, bool &pack_error, bool &) const {
pack_uint64(DCPackData &, uint64_t, bool &pack_error, bool &) const {
pack_error = true;
}
@ -284,7 +284,7 @@ unpack_uint(const char *, size_t, size_t &, unsigned int &, bool &pack_error, bo
* Unpacks the current numeric or string value from the stream.
*/
void DCPackerInterface::
unpack_int64(const char *, size_t, size_t &, PN_int64 &, bool &pack_error, bool &) const {
unpack_int64(const char *, size_t, size_t &, int64_t &, bool &pack_error, bool &) const {
pack_error = true;
}
@ -292,7 +292,7 @@ unpack_int64(const char *, size_t, size_t &, PN_int64 &, bool &pack_error, bool
* Unpacks the current numeric or string value from the stream.
*/
void DCPackerInterface::
unpack_uint64(const char *, size_t, size_t &, PN_uint64 &, bool &pack_error, bool &) const {
unpack_uint64(const char *, size_t, size_t &, uint64_t &, bool &pack_error, bool &) const {
pack_error = true;
}

View File

@ -107,9 +107,9 @@ public:
bool &pack_error, bool &range_error) const;
virtual void pack_uint(DCPackData &pack_data, unsigned int value,
bool &pack_error, bool &range_error) const;
virtual void pack_int64(DCPackData &pack_data, PN_int64 value,
virtual void pack_int64(DCPackData &pack_data, int64_t value,
bool &pack_error, bool &range_error) const;
virtual void pack_uint64(DCPackData &pack_data, PN_uint64 value,
virtual void pack_uint64(DCPackData &pack_data, uint64_t value,
bool &pack_error, bool &range_error) const;
virtual void pack_string(DCPackData &pack_data, const string &value,
bool &pack_error, bool &range_error) const;
@ -122,9 +122,9 @@ public:
virtual void unpack_uint(const char *data, size_t length, size_t &p,
unsigned int &value, bool &pack_error, bool &range_error) const;
virtual void unpack_int64(const char *data, size_t length, size_t &p,
PN_int64 &value, bool &pack_error, bool &range_error) const;
int64_t &value, bool &pack_error, bool &range_error) const;
virtual void unpack_uint64(const char *data, size_t length, size_t &p,
PN_uint64 &value, bool &pack_error, bool &range_error) const;
uint64_t &value, bool &pack_error, bool &range_error) const;
virtual void unpack_string(const char *data, size_t length, size_t &p,
string &value, bool &pack_error, bool &range_error) const;
virtual bool unpack_validate(const char *data, size_t length, size_t &p,
@ -138,30 +138,30 @@ public:
INLINE static void do_pack_int8(char *buffer, int value);
INLINE static void do_pack_int16(char *buffer, int value);
INLINE static void do_pack_int32(char *buffer, int value);
INLINE static void do_pack_int64(char *buffer, PN_int64 value);
INLINE static void do_pack_int64(char *buffer, int64_t value);
INLINE static void do_pack_uint8(char *buffer, unsigned int value);
INLINE static void do_pack_uint16(char *buffer, unsigned int value);
INLINE static void do_pack_uint32(char *buffer, unsigned int value);
INLINE static void do_pack_uint64(char *buffer, PN_uint64 value);
INLINE static void do_pack_uint64(char *buffer, uint64_t value);
INLINE static void do_pack_float64(char *buffer, double value);
INLINE static int do_unpack_int8(const char *buffer);
INLINE static int do_unpack_int16(const char *buffer);
INLINE static int do_unpack_int32(const char *buffer);
INLINE static PN_int64 do_unpack_int64(const char *buffer);
INLINE static int64_t do_unpack_int64(const char *buffer);
INLINE static unsigned int do_unpack_uint8(const char *buffer);
INLINE static unsigned int do_unpack_uint16(const char *buffer);
INLINE static unsigned int do_unpack_uint32(const char *buffer);
INLINE static PN_uint64 do_unpack_uint64(const char *buffer);
INLINE static uint64_t do_unpack_uint64(const char *buffer);
INLINE static double do_unpack_float64(const char *buffer);
INLINE static void validate_int_limits(int value, int num_bits,
bool &range_error);
INLINE static void validate_int64_limits(PN_int64 value, int num_bits,
INLINE static void validate_int64_limits(int64_t value, int num_bits,
bool &range_error);
INLINE static void validate_uint_limits(unsigned int value, int num_bits,
bool &range_error);
INLINE static void validate_uint64_limits(PN_uint64 value, int num_bits,
INLINE static void validate_uint64_limits(uint64_t value, int num_bits,
bool &range_error);
const DCPackerCatalog *get_catalog() const;

View File

@ -48,8 +48,8 @@ public:
union U {
int s_int;
unsigned int s_uint;
PN_int64 int64;
PN_uint64 uint64;
int64_t int64;
uint64_t uint64;
double real;
bool flag;
DCClass *dclass;

View File

@ -313,7 +313,7 @@ set_modulus(double modulus) {
bool range_error = false;
_double_modulus = modulus * _divisor;
_uint64_modulus = (PN_uint64)floor(_double_modulus + 0.5);
_uint64_modulus = (uint64_t)floor(_double_modulus + 0.5);
_uint_modulus = (unsigned int)_uint64_modulus;
// Check the range. The legitimate range for a modulus value is 1 through
@ -413,8 +413,8 @@ set_range(const DCDoubleRange &range) {
case ST_int8array:
_int_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5);
PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5);
int64_t min = (int64_t)floor(range.get_min(i) * _divisor + 0.5);
int64_t max = (int64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_int64_limits(min, 8, range_error);
validate_int64_limits(max, 8, range_error);
_int_range.add_range((int)min, (int)max);
@ -425,8 +425,8 @@ set_range(const DCDoubleRange &range) {
case ST_int16array:
_int_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5);
PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5);
int64_t min = (int64_t)floor(range.get_min(i) * _divisor + 0.5);
int64_t max = (int64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_int64_limits(min, 16, range_error);
validate_int64_limits(max, 16, range_error);
_int_range.add_range((int)min, (int)max);
@ -437,8 +437,8 @@ set_range(const DCDoubleRange &range) {
case ST_int32array:
_int_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5);
PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5);
int64_t min = (int64_t)floor(range.get_min(i) * _divisor + 0.5);
int64_t max = (int64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_int64_limits(min, 32, range_error);
validate_int64_limits(max, 32, range_error);
_int_range.add_range((int)min, (int)max);
@ -448,8 +448,8 @@ set_range(const DCDoubleRange &range) {
case ST_int64:
_int64_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5);
PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5);
int64_t min = (int64_t)floor(range.get_min(i) * _divisor + 0.5);
int64_t max = (int64_t)floor(range.get_max(i) * _divisor + 0.5);
_int64_range.add_range(min, max);
}
break;
@ -459,8 +459,8 @@ set_range(const DCDoubleRange &range) {
case ST_uint8array:
_uint_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
uint64_t min = (uint64_t)floor(range.get_min(i) * _divisor + 0.5);
uint64_t max = (uint64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_uint64_limits(min, 8, range_error);
validate_uint64_limits(max, 8, range_error);
_uint_range.add_range((unsigned int)min, (unsigned int)max);
@ -471,8 +471,8 @@ set_range(const DCDoubleRange &range) {
case ST_uint16array:
_uint_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
uint64_t min = (uint64_t)floor(range.get_min(i) * _divisor + 0.5);
uint64_t max = (uint64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_uint64_limits(min, 16, range_error);
validate_uint64_limits(max, 16, range_error);
_uint_range.add_range((unsigned int)min, (unsigned int)max);
@ -483,8 +483,8 @@ set_range(const DCDoubleRange &range) {
case ST_uint32array:
_uint_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
uint64_t min = (uint64_t)floor(range.get_min(i) * _divisor + 0.5);
uint64_t max = (uint64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_uint64_limits(min, 32, range_error);
validate_uint64_limits(max, 32, range_error);
_uint_range.add_range((unsigned int)min, (unsigned int)max);
@ -494,8 +494,8 @@ set_range(const DCDoubleRange &range) {
case ST_uint64:
_uint64_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
uint64_t min = (uint64_t)floor(range.get_min(i) * _divisor + 0.5);
uint64_t max = (uint64_t)floor(range.get_max(i) * _divisor + 0.5);
_uint64_range.add_range(min, max);
}
break;
@ -513,8 +513,8 @@ set_range(const DCDoubleRange &range) {
case ST_blob:
_uint_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
uint64_t min = (uint64_t)floor(range.get_min(i) * _divisor + 0.5);
uint64_t max = (uint64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_uint64_limits(min, 16, range_error);
validate_uint64_limits(max, 16, range_error);
_uint_range.add_range((unsigned int)min, (unsigned int)max);
@ -536,8 +536,8 @@ set_range(const DCDoubleRange &range) {
case ST_blob32:
_uint_range.clear();
for (i = 0; i < num_ranges; i++) {
PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5);
PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5);
uint64_t min = (uint64_t)floor(range.get_min(i) * _divisor + 0.5);
uint64_t max = (uint64_t)floor(range.get_max(i) * _divisor + 0.5);
validate_uint64_limits(min, 32, range_error);
validate_uint64_limits(max, 32, range_error);
_uint_range.add_range((unsigned int)min, (unsigned int)max);
@ -634,7 +634,7 @@ pack_double(DCPackData &pack_data, double value,
case ST_int64:
{
PN_int64 int64_value = (PN_int64)floor(real_value + 0.5);
int64_t int64_value = (int64_t)floor(real_value + 0.5);
_int64_range.validate(int64_value, range_error);
do_pack_int64(pack_data.get_write_pointer(8), int64_value);
}
@ -669,7 +669,7 @@ pack_double(DCPackData &pack_data, double value,
case ST_uint64:
{
PN_uint64 int64_value = (PN_uint64)floor(real_value + 0.5);
uint64_t int64_value = (uint64_t)floor(real_value + 0.5);
_uint64_range.validate(int64_value, range_error);
do_pack_uint64(pack_data.get_write_pointer(8), int64_value);
}
@ -696,7 +696,7 @@ pack_int(DCPackData &pack_data, int value,
if (value != 0 && (int_value / value) != (int)_divisor) {
// If we've experienced overflow after applying the divisor, pack it as an
// int64 instead.
pack_int64(pack_data, (PN_int64)value, pack_error, range_error);
pack_int64(pack_data, (int64_t)value, pack_error, range_error);
return;
}
@ -859,9 +859,9 @@ pack_uint(DCPackData &pack_data, unsigned int value,
* Packs the indicated numeric or string value into the stream.
*/
void DCSimpleParameter::
pack_int64(DCPackData &pack_data, PN_int64 value,
pack_int64(DCPackData &pack_data, int64_t value,
bool &pack_error, bool &range_error) const {
PN_int64 int_value = value * _divisor;
int64_t int_value = value * _divisor;
if (_has_modulus && _uint64_modulus != 0) {
if (int_value < 0) {
int_value = _uint64_modulus - 1 - (-int_value - 1) % _uint64_modulus;
@ -899,35 +899,35 @@ pack_int64(DCPackData &pack_data, PN_int64 value,
if (int_value < 0) {
range_error = true;
}
_uint_range.validate((unsigned int)(PN_uint64)int_value, range_error);
validate_uint64_limits((PN_uint64)int_value, 8, range_error);
do_pack_uint8(pack_data.get_write_pointer(1), (unsigned int)(PN_uint64)int_value);
_uint_range.validate((unsigned int)(uint64_t)int_value, range_error);
validate_uint64_limits((uint64_t)int_value, 8, range_error);
do_pack_uint8(pack_data.get_write_pointer(1), (unsigned int)(uint64_t)int_value);
break;
case ST_uint16:
if (int_value < 0) {
range_error = true;
}
_uint_range.validate((unsigned int)(PN_uint64)int_value, range_error);
validate_uint64_limits((PN_uint64)int_value, 16, range_error);
do_pack_uint16(pack_data.get_write_pointer(2), (unsigned int)(PN_uint64)int_value);
_uint_range.validate((unsigned int)(uint64_t)int_value, range_error);
validate_uint64_limits((uint64_t)int_value, 16, range_error);
do_pack_uint16(pack_data.get_write_pointer(2), (unsigned int)(uint64_t)int_value);
break;
case ST_uint32:
if (int_value < 0) {
range_error = true;
}
_uint_range.validate((unsigned int)(PN_uint64)int_value, range_error);
validate_uint64_limits((PN_uint64)int_value, 32, range_error);
do_pack_uint32(pack_data.get_write_pointer(4), (unsigned int)(PN_uint64)int_value);
_uint_range.validate((unsigned int)(uint64_t)int_value, range_error);
validate_uint64_limits((uint64_t)int_value, 32, range_error);
do_pack_uint32(pack_data.get_write_pointer(4), (unsigned int)(uint64_t)int_value);
break;
case ST_uint64:
if (int_value < 0) {
range_error = true;
}
_uint64_range.validate((PN_uint64)int_value, range_error);
do_pack_uint64(pack_data.get_write_pointer(8), (PN_uint64)int_value);
_uint64_range.validate((uint64_t)int_value, range_error);
do_pack_uint64(pack_data.get_write_pointer(8), (uint64_t)int_value);
break;
case ST_float64:
@ -944,47 +944,47 @@ pack_int64(DCPackData &pack_data, PN_int64 value,
* Packs the indicated numeric or string value into the stream.
*/
void DCSimpleParameter::
pack_uint64(DCPackData &pack_data, PN_uint64 value,
pack_uint64(DCPackData &pack_data, uint64_t value,
bool &pack_error, bool &range_error) const {
PN_uint64 int_value = value * _divisor;
uint64_t int_value = value * _divisor;
if (_has_modulus && _uint64_modulus != 0) {
int_value = int_value % _uint64_modulus;
}
switch (_type) {
case ST_int8:
if ((PN_int64)int_value < 0) {
if ((int64_t)int_value < 0) {
range_error = true;
}
_int_range.validate((int)(PN_int64)int_value, range_error);
validate_int64_limits((PN_int64)int_value, 8, range_error);
do_pack_int8(pack_data.get_write_pointer(1), (int)(PN_int64)int_value);
_int_range.validate((int)(int64_t)int_value, range_error);
validate_int64_limits((int64_t)int_value, 8, range_error);
do_pack_int8(pack_data.get_write_pointer(1), (int)(int64_t)int_value);
break;
case ST_int16:
if ((PN_int64)int_value < 0) {
if ((int64_t)int_value < 0) {
range_error = true;
}
_int_range.validate((int)(PN_int64)int_value, range_error);
validate_int64_limits((PN_int64)int_value, 16, range_error);
do_pack_int16(pack_data.get_write_pointer(2), (int)(PN_int64)int_value);
_int_range.validate((int)(int64_t)int_value, range_error);
validate_int64_limits((int64_t)int_value, 16, range_error);
do_pack_int16(pack_data.get_write_pointer(2), (int)(int64_t)int_value);
break;
case ST_int32:
if ((PN_int64)int_value < 0) {
if ((int64_t)int_value < 0) {
range_error = true;
}
_int_range.validate((int)(PN_int64)int_value, range_error);
validate_int64_limits((PN_int64)int_value, 32, range_error);
do_pack_int32(pack_data.get_write_pointer(4), (int)(PN_int64)int_value);
_int_range.validate((int)(int64_t)int_value, range_error);
validate_int64_limits((int64_t)int_value, 32, range_error);
do_pack_int32(pack_data.get_write_pointer(4), (int)(int64_t)int_value);
break;
case ST_int64:
if ((PN_int64)int_value < 0) {
if ((int64_t)int_value < 0) {
range_error = true;
}
_int64_range.validate((PN_int64)int_value, range_error);
do_pack_int64(pack_data.get_write_pointer(8), (PN_int64)int_value);
_int64_range.validate((int64_t)int_value, range_error);
do_pack_int64(pack_data.get_write_pointer(8), (int64_t)int_value);
break;
case ST_char:
@ -1213,7 +1213,7 @@ unpack_double(const char *data, size_t length, size_t &p, double &value,
pack_error = true;
return;
}
PN_int64 int_value = do_unpack_int64(data + p);
int64_t int_value = do_unpack_int64(data + p);
_int64_range.validate(int_value, range_error);
value = (double)int_value;
p += 8;
@ -1266,7 +1266,7 @@ unpack_double(const char *data, size_t length, size_t &p, double &value,
pack_error = true;
return;
}
PN_uint64 uint_value = do_unpack_uint64(data + p);
uint64_t uint_value = do_unpack_uint64(data + p);
_uint64_range.validate(uint_value, range_error);
value = (double)uint_value;
p += 8;
@ -1340,7 +1340,7 @@ unpack_int(const char *data, size_t length, size_t &p, int &value,
pack_error = true;
return;
}
PN_int64 int_value = do_unpack_uint64(data + p);
int64_t int_value = do_unpack_uint64(data + p);
_int64_range.validate(int_value, range_error);
value = (int)int_value;
if (value != int_value) {
@ -1400,7 +1400,7 @@ unpack_int(const char *data, size_t length, size_t &p, int &value,
pack_error = true;
return;
}
PN_uint64 uint_value = do_unpack_uint64(data + p);
uint64_t uint_value = do_unpack_uint64(data + p);
_uint64_range.validate(uint_value, range_error);
value = (int)(unsigned int)uint_value;
if ((unsigned int)value != uint_value || value < 0) {
@ -1496,7 +1496,7 @@ unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value,
pack_error = true;
return;
}
PN_int64 int_value = do_unpack_int64(data + p);
int64_t int_value = do_unpack_int64(data + p);
_int64_range.validate(int_value, range_error);
if (int_value < 0) {
pack_error = true;
@ -1546,7 +1546,7 @@ unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value,
pack_error = true;
return;
}
PN_uint64 uint_value = do_unpack_uint64(data + p);
uint64_t uint_value = do_unpack_uint64(data + p);
_uint64_range.validate(uint_value, range_error);
value = (unsigned int)uint_value;
if (value != uint_value) {
@ -1585,7 +1585,7 @@ unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value,
* Unpacks the current numeric or string value from the stream.
*/
void DCSimpleParameter::
unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
unpack_int64(const char *data, size_t length, size_t &p, int64_t &value,
bool &pack_error, bool &range_error) const {
switch (_type) {
case ST_int8:
@ -1596,7 +1596,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
}
int int_value = do_unpack_int8(data + p);
_int_range.validate(int_value, range_error);
value = (PN_int64)int_value;
value = (int64_t)int_value;
p++;
}
break;
@ -1609,7 +1609,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
}
int int_value = do_unpack_int16(data + p);
_int_range.validate(int_value, range_error);
value = (PN_int64)int_value;
value = (int64_t)int_value;
p += 2;
}
break;
@ -1622,7 +1622,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
}
int int_value = do_unpack_int32(data + p);
_int_range.validate(int_value, range_error);
value = (PN_int64)int_value;
value = (int64_t)int_value;
p += 4;
}
break;
@ -1646,7 +1646,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
}
unsigned int uint_value = do_unpack_uint8(data + p);
_uint_range.validate(uint_value, range_error);
value = (PN_int64)(int)uint_value;
value = (int64_t)(int)uint_value;
p++;
}
break;
@ -1659,7 +1659,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
}
unsigned int uint_value = do_unpack_uint16(data + p);
_uint_range.validate(uint_value, range_error);
value = (PN_int64)(int)uint_value;
value = (int64_t)(int)uint_value;
p += 2;
}
break;
@ -1672,7 +1672,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
}
unsigned int uint_value = do_unpack_uint32(data + p);
_uint_range.validate(uint_value, range_error);
value = (PN_int64)(int)uint_value;
value = (int64_t)(int)uint_value;
p += 4;
}
break;
@ -1683,9 +1683,9 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
pack_error = true;
return;
}
PN_uint64 uint_value = do_unpack_uint64(data + p);
uint64_t uint_value = do_unpack_uint64(data + p);
_uint64_range.validate(uint_value, range_error);
value = (PN_int64)uint_value;
value = (int64_t)uint_value;
if (value < 0) {
pack_error = true;
}
@ -1701,7 +1701,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
}
double real_value = do_unpack_float64(data + p);
_double_range.validate(real_value, range_error);
value = (PN_int64)real_value;
value = (int64_t)real_value;
p += 8;
}
break;
@ -1722,7 +1722,7 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value,
* Unpacks the current numeric or string value from the stream.
*/
void DCSimpleParameter::
unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
unpack_uint64(const char *data, size_t length, size_t &p, uint64_t &value,
bool &pack_error, bool &range_error) const {
switch (_type) {
case ST_int8:
@ -1736,7 +1736,7 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
if (int_value < 0) {
pack_error = true;
}
value = (PN_uint64)(unsigned int)int_value;
value = (uint64_t)(unsigned int)int_value;
p++;
}
break;
@ -1752,7 +1752,7 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
if (int_value < 0) {
pack_error = true;
}
value = (PN_uint64)(unsigned int)int_value;
value = (uint64_t)(unsigned int)int_value;
p += 2;
}
break;
@ -1768,7 +1768,7 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
if (int_value < 0) {
pack_error = true;
}
value = (PN_uint64)(unsigned int)int_value;
value = (uint64_t)(unsigned int)int_value;
p += 4;
}
break;
@ -1779,12 +1779,12 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
pack_error = true;
return;
}
PN_int64 int_value = do_unpack_int64(data + p);
int64_t int_value = do_unpack_int64(data + p);
_int64_range.validate(int_value, range_error);
if (int_value < 0) {
pack_error = true;
}
value = (PN_uint64)int_value;
value = (uint64_t)int_value;
p += 8;
}
break;
@ -1798,7 +1798,7 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
}
unsigned int uint_value = do_unpack_uint8(data + p);
_uint_range.validate(uint_value, range_error);
value = (PN_uint64)uint_value;
value = (uint64_t)uint_value;
p++;
}
break;
@ -1811,7 +1811,7 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
}
unsigned int uint_value = do_unpack_uint16(data + p);
_uint_range.validate(uint_value, range_error);
value = (PN_uint64)uint_value;
value = (uint64_t)uint_value;
p += 2;
}
break;
@ -1824,7 +1824,7 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
}
unsigned int uint_value = do_unpack_uint32(data + p);
_uint_range.validate(uint_value, range_error);
value = (PN_uint64)uint_value;
value = (uint64_t)uint_value;
p += 4;
}
break;
@ -1847,7 +1847,7 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value,
}
double real_value = do_unpack_float64(data + p);
_double_range.validate(real_value, range_error);
value = (PN_uint64)real_value;
value = (uint64_t)real_value;
p += 8;
}
break;
@ -1990,7 +1990,7 @@ unpack_validate(const char *data, size_t length, size_t &p,
pack_error = true;
return true;
}
PN_int64 int_value = do_unpack_int64(data + p);
int64_t int_value = do_unpack_int64(data + p);
_int64_range.validate(int_value, range_error);
p += 8;
}
@ -2039,7 +2039,7 @@ unpack_validate(const char *data, size_t length, size_t &p,
pack_error = true;
return true;
}
PN_uint64 uint_value = do_unpack_uint64(data + p);
uint64_t uint_value = do_unpack_uint64(data + p);
_uint64_range.validate(uint_value, range_error);
p += 8;
}

View File

@ -56,9 +56,9 @@ public:
bool &pack_error, bool &range_error) const;
virtual void pack_uint(DCPackData &pack_data, unsigned int value,
bool &pack_error, bool &range_error) const;
virtual void pack_int64(DCPackData &pack_data, PN_int64 value,
virtual void pack_int64(DCPackData &pack_data, int64_t value,
bool &pack_error, bool &range_error) const;
virtual void pack_uint64(DCPackData &pack_data, PN_uint64 value,
virtual void pack_uint64(DCPackData &pack_data, uint64_t value,
bool &pack_error, bool &range_error) const;
virtual void pack_string(DCPackData &pack_data, const string &value,
bool &pack_error, bool &range_error) const;
@ -71,9 +71,9 @@ public:
virtual void unpack_uint(const char *data, size_t length, size_t &p,
unsigned int &value, bool &pack_error, bool &range_error) const;
virtual void unpack_int64(const char *data, size_t length, size_t &p,
PN_int64 &value, bool &pack_error, bool &range_error) const;
int64_t &value, bool &pack_error, bool &range_error) const;
virtual void unpack_uint64(const char *data, size_t length, size_t &p,
PN_uint64 &value, bool &pack_error, bool &range_error) const;
uint64_t &value, bool &pack_error, bool &range_error) const;
virtual void unpack_string(const char *data, size_t length, size_t &p,
string &value, bool &pack_error, bool &range_error) const;
virtual bool unpack_validate(const char *data, size_t length, size_t &p,
@ -125,7 +125,7 @@ private:
// All of these modulus values will be filled in, regardless of the type.
unsigned int _uint_modulus;
PN_uint64 _uint64_modulus;
uint64_t _uint64_modulus;
double _double_modulus;
static DCClassParameter *_uint32uint8_type;

View File

@ -102,17 +102,7 @@ typedef string Filename;
#define pmap map
#define pset set
#ifdef WIN32
typedef __int64 PN_int64;
typedef unsigned __int64 PN_uint64;
#else
typedef long long PN_int64;
typedef unsigned long long PN_uint64;
#endif
typedef unsigned char PN_uint8;
typedef unsigned short PN_uint16;
typedef unsigned int PN_uint32;
#include <stdint.h>
typedef ifstream pifstream;
typedef ofstream pofstream;
@ -121,8 +111,8 @@ typedef fstream pfstream;
#endif // WITHIN_PANDA
// typedef unsigned long CHANNEL_TYPE;
typedef PN_uint64 CHANNEL_TYPE;
typedef PN_uint32 DOID_TYPE;
typedef PN_uint32 ZONEID_TYPE;
typedef uint64_t CHANNEL_TYPE;
typedef uint32_t DOID_TYPE;
typedef uint32_t ZONEID_TYPE;
#endif // DCBASE_H

View File

@ -48,10 +48,10 @@ class DirectButtons(ButtonNode, DirectObject):
def __init__(self, vrpnClient, device):
# Keep track of number of buttons created
DirectButtons.buttonCount += 1
# Create a unique name for this button object
self.name = 'DirectButtons-' + repr(DirectButtons.buttonCount)
# Create a new button node for the given device
ButtonNode.__init__(self, vrpnClient, device)
# Create a unique name for this button object
self.name = 'DirectButtons-' + repr(DirectButtons.buttonCount)
# Attach node to data graph
self.nodePath = myBase.dataRoot.attachNewNode(self)
@ -86,10 +86,10 @@ class DirectAnalogs(AnalogNode, DirectObject):
def __init__(self, vrpnClient, device):
# Keep track of number of analogs created
DirectAnalogs.analogCount += 1
# Create a unique name for this analog object
self.name = 'DirectAnalogs-' + repr(DirectAnalogs.analogCount)
# Create a new analog node for the given device
AnalogNode.__init__(self, vrpnClient, device)
# Create a unique name for this analog object
self.name = 'DirectAnalogs-' + repr(DirectAnalogs.analogCount)
# Attach node to data graph
self.nodePath = myBase.dataRoot.attachNewNode(self)
# See if any of the general analog parameters are dconfig'd
@ -182,10 +182,10 @@ class DirectTracker(TrackerNode, DirectObject):
def __init__(self, vrpnClient, device):
# Keep track of number of trackers created
DirectTracker.trackerCount += 1
# Create a unique name for this tracker object
self.name = 'DirectTracker-' + repr(DirectTracker.trackerCount)
# Create a new tracker node for the given device
TrackerNode.__init__(self, vrpnClient, device)
# Create a unique name for this tracker object
self.name = 'DirectTracker-' + repr(DirectTracker.trackerCount)
# Attach node to data graph
self.nodePath = myBase.dataRoot.attachNewNode(self)
@ -209,10 +209,10 @@ class DirectDials(DialNode, DirectObject):
def __init__(self, vrpnClient, device):
# Keep track of number of dials created
DirectDials.dialCount += 1
# Create a unique name for this dial object
self.name = 'DirectDials-' + repr(DirectDials.dialCount)
# Create a new dial node for the given device
DialNode.__init__(self, vrpnClient, device)
# Create a unique name for this dial object
self.name = 'DirectDials-' + repr(DirectDials.dialCount)
# Attach node to data graph
self.nodePath = myBase.dataRoot.attachNewNode(self)
@ -249,6 +249,8 @@ class DirectTimecodeReader(AnalogNode, DirectObject):
def __init__(self, vrpnClient, device):
# Keep track of number of timecodeReader created
DirectTimecodeReader.timecodeReaderCount += 1
# Create a new dial node for the given device
AnalogNode.__init__(self, vrpnClient, device)
# Create a unique name for this dial object
self.name = ('DirectTimecodeReader-' +
repr(DirectTimecodeReader.timecodeReaderCount))
@ -257,8 +259,6 @@ class DirectTimecodeReader(AnalogNode, DirectObject):
self.seconds = 0
self.minutes = 0
self.hours = 0
# Create a new dial node for the given device
AnalogNode.__init__(self, vrpnClient, device)
# Attach node to data graph
self.nodePath = myBase.dataRoot.attachNewNode(self)

View File

@ -184,7 +184,7 @@ d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_std
*
*/
INLINE void CDistributedSmoothNodeBase::
d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_uint64 l) {
d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, uint64_t l) {
// cout << "d_setSmPosHprL: " << x << ", " << y << ", " << z << ", " << h <<
// ", " << p << ", " << r << l << endl;
DCPacker packer;

View File

@ -358,7 +358,7 @@ finish_send_update(DCPacker &packer) {
* Appends the timestamp and sends the update.
*/
void CDistributedSmoothNodeBase::
set_curr_l(PN_uint64 l) {
set_curr_l(uint64_t l) {
_currL[1] = l;
}

View File

@ -51,7 +51,7 @@ PUBLISHED:
void broadcast_pos_hpr_xyh();
void broadcast_pos_hpr_xy();
void set_curr_l(PN_uint64 l);
void set_curr_l(uint64_t l);
void print_curr_l();
private:
@ -67,7 +67,7 @@ private:
INLINE void d_setSmXYH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat h);
INLINE void d_setSmXYZH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h);
INLINE void d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r);
INLINE void d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_uint64 l);
INLINE void d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, uint64_t l);
void begin_send_update(DCPacker &packer, const string &field_name);
void finish_send_update(DCPacker &packer);
@ -97,7 +97,7 @@ private:
bool _store_stop;
// contains most recently sent location info as index 0, index 1 contains
// most recently set location info
PN_uint64 _currL[2];
uint64_t _currL[2];
};
#include "cDistributedSmoothNodeBase.I"

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* A Bison parser, made by GNU Bison 2.7. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 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/>. */
@ -26,13 +26,13 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_CPPYY_BUILT_TMP_CPPBISON_YXX_H_INCLUDED
# define YY_CPPYY_BUILT_TMP_CPPBISON_YXX_H_INCLUDED
/* Enabling traces. */
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
@ -40,134 +40,135 @@
extern int cppyydebug;
#endif
/* Tokens. */
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
REAL = 258,
INTEGER = 259,
CHAR_TOK = 260,
SIMPLE_STRING = 261,
SIMPLE_IDENTIFIER = 262,
STRING_LITERAL = 263,
CUSTOM_LITERAL = 264,
IDENTIFIER = 265,
TYPENAME_IDENTIFIER = 266,
SCOPING = 267,
TYPEDEFNAME = 268,
ELLIPSIS = 269,
OROR = 270,
ANDAND = 271,
EQCOMPARE = 272,
NECOMPARE = 273,
LECOMPARE = 274,
GECOMPARE = 275,
LSHIFT = 276,
RSHIFT = 277,
POINTSAT_STAR = 278,
DOT_STAR = 279,
UNARY = 280,
UNARY_NOT = 281,
UNARY_NEGATE = 282,
UNARY_MINUS = 283,
UNARY_PLUS = 284,
UNARY_STAR = 285,
UNARY_REF = 286,
POINTSAT = 287,
SCOPE = 288,
PLUSPLUS = 289,
MINUSMINUS = 290,
TIMESEQUAL = 291,
DIVIDEEQUAL = 292,
MODEQUAL = 293,
PLUSEQUAL = 294,
MINUSEQUAL = 295,
OREQUAL = 296,
ANDEQUAL = 297,
XOREQUAL = 298,
LSHIFTEQUAL = 299,
RSHIFTEQUAL = 300,
KW_ALIGNAS = 301,
KW_ALIGNOF = 302,
KW_AUTO = 303,
KW_BEGIN_PUBLISH = 304,
KW_BLOCKING = 305,
KW_BOOL = 306,
KW_CATCH = 307,
KW_CHAR = 308,
KW_CHAR16_T = 309,
KW_CHAR32_T = 310,
KW_CLASS = 311,
KW_CONST = 312,
KW_CONSTEXPR = 313,
KW_CONST_CAST = 314,
KW_DECLTYPE = 315,
KW_DEFAULT = 316,
KW_DELETE = 317,
KW_DOUBLE = 318,
KW_DYNAMIC_CAST = 319,
KW_ELSE = 320,
KW_END_PUBLISH = 321,
KW_ENUM = 322,
KW_EXTENSION = 323,
KW_EXTERN = 324,
KW_EXPLICIT = 325,
KW_PUBLISHED = 326,
KW_FALSE = 327,
KW_FINAL = 328,
KW_FLOAT = 329,
KW_FRIEND = 330,
KW_FOR = 331,
KW_GOTO = 332,
KW_IF = 333,
KW_INLINE = 334,
KW_INT = 335,
KW_LONG = 336,
KW_MAKE_PROPERTY = 337,
KW_MAKE_PROPERTY2 = 338,
KW_MAKE_SEQ = 339,
KW_MUTABLE = 340,
KW_NAMESPACE = 341,
KW_NEW = 342,
KW_NOEXCEPT = 343,
KW_NULLPTR = 344,
KW_OPERATOR = 345,
KW_OVERRIDE = 346,
KW_PRIVATE = 347,
KW_PROTECTED = 348,
KW_PUBLIC = 349,
KW_REGISTER = 350,
KW_REINTERPRET_CAST = 351,
KW_RETURN = 352,
KW_SHORT = 353,
KW_SIGNED = 354,
KW_SIZEOF = 355,
KW_STATIC = 356,
KW_STATIC_ASSERT = 357,
KW_STATIC_CAST = 358,
KW_STRUCT = 359,
KW_TEMPLATE = 360,
KW_THREAD_LOCAL = 361,
KW_THROW = 362,
KW_TRUE = 363,
KW_TRY = 364,
KW_TYPEDEF = 365,
KW_TYPEID = 366,
KW_TYPENAME = 367,
KW_UNION = 368,
KW_UNSIGNED = 369,
KW_USING = 370,
KW_VIRTUAL = 371,
KW_VOID = 372,
KW_VOLATILE = 373,
KW_WCHAR_T = 374,
KW_WHILE = 375,
START_CPP = 376,
START_CONST_EXPR = 377,
START_TYPE = 378
};
enum yytokentype
{
REAL = 258,
INTEGER = 259,
CHAR_TOK = 260,
SIMPLE_STRING = 261,
SIMPLE_IDENTIFIER = 262,
STRING_LITERAL = 263,
CUSTOM_LITERAL = 264,
IDENTIFIER = 265,
TYPENAME_IDENTIFIER = 266,
SCOPING = 267,
TYPEDEFNAME = 268,
ELLIPSIS = 269,
OROR = 270,
ANDAND = 271,
EQCOMPARE = 272,
NECOMPARE = 273,
LECOMPARE = 274,
GECOMPARE = 275,
LSHIFT = 276,
RSHIFT = 277,
POINTSAT_STAR = 278,
DOT_STAR = 279,
UNARY = 280,
UNARY_NOT = 281,
UNARY_NEGATE = 282,
UNARY_MINUS = 283,
UNARY_PLUS = 284,
UNARY_STAR = 285,
UNARY_REF = 286,
POINTSAT = 287,
SCOPE = 288,
PLUSPLUS = 289,
MINUSMINUS = 290,
TIMESEQUAL = 291,
DIVIDEEQUAL = 292,
MODEQUAL = 293,
PLUSEQUAL = 294,
MINUSEQUAL = 295,
OREQUAL = 296,
ANDEQUAL = 297,
XOREQUAL = 298,
LSHIFTEQUAL = 299,
RSHIFTEQUAL = 300,
KW_ALIGNAS = 301,
KW_ALIGNOF = 302,
KW_AUTO = 303,
KW_BEGIN_PUBLISH = 304,
KW_BLOCKING = 305,
KW_BOOL = 306,
KW_CATCH = 307,
KW_CHAR = 308,
KW_CHAR16_T = 309,
KW_CHAR32_T = 310,
KW_CLASS = 311,
KW_CONST = 312,
KW_CONSTEXPR = 313,
KW_CONST_CAST = 314,
KW_DECLTYPE = 315,
KW_DEFAULT = 316,
KW_DELETE = 317,
KW_DOUBLE = 318,
KW_DYNAMIC_CAST = 319,
KW_ELSE = 320,
KW_END_PUBLISH = 321,
KW_ENUM = 322,
KW_EXTENSION = 323,
KW_EXTERN = 324,
KW_EXPLICIT = 325,
KW_PUBLISHED = 326,
KW_FALSE = 327,
KW_FINAL = 328,
KW_FLOAT = 329,
KW_FRIEND = 330,
KW_FOR = 331,
KW_GOTO = 332,
KW_IF = 333,
KW_INLINE = 334,
KW_INT = 335,
KW_LONG = 336,
KW_MAKE_MAP_PROPERTY = 337,
KW_MAKE_PROPERTY = 338,
KW_MAKE_PROPERTY2 = 339,
KW_MAKE_SEQ = 340,
KW_MAKE_SEQ_PROPERTY = 341,
KW_MUTABLE = 342,
KW_NAMESPACE = 343,
KW_NEW = 344,
KW_NOEXCEPT = 345,
KW_NULLPTR = 346,
KW_OPERATOR = 347,
KW_OVERRIDE = 348,
KW_PRIVATE = 349,
KW_PROTECTED = 350,
KW_PUBLIC = 351,
KW_REGISTER = 352,
KW_REINTERPRET_CAST = 353,
KW_RETURN = 354,
KW_SHORT = 355,
KW_SIGNED = 356,
KW_SIZEOF = 357,
KW_STATIC = 358,
KW_STATIC_ASSERT = 359,
KW_STATIC_CAST = 360,
KW_STRUCT = 361,
KW_TEMPLATE = 362,
KW_THREAD_LOCAL = 363,
KW_THROW = 364,
KW_TRUE = 365,
KW_TRY = 366,
KW_TYPEDEF = 367,
KW_TYPEID = 368,
KW_TYPENAME = 369,
KW_UNION = 370,
KW_UNSIGNED = 371,
KW_USING = 372,
KW_VIRTUAL = 373,
KW_VOID = 374,
KW_VOLATILE = 375,
KW_WCHAR_T = 376,
KW_WHILE = 377,
START_CPP = 378,
START_CONST_EXPR = 379,
START_TYPE = 380
};
#endif
/* Tokens. */
#define REAL 258
@ -249,83 +250,69 @@ extern int cppyydebug;
#define KW_INLINE 334
#define KW_INT 335
#define KW_LONG 336
#define KW_MAKE_PROPERTY 337
#define KW_MAKE_PROPERTY2 338
#define KW_MAKE_SEQ 339
#define KW_MUTABLE 340
#define KW_NAMESPACE 341
#define KW_NEW 342
#define KW_NOEXCEPT 343
#define KW_NULLPTR 344
#define KW_OPERATOR 345
#define KW_OVERRIDE 346
#define KW_PRIVATE 347
#define KW_PROTECTED 348
#define KW_PUBLIC 349
#define KW_REGISTER 350
#define KW_REINTERPRET_CAST 351
#define KW_RETURN 352
#define KW_SHORT 353
#define KW_SIGNED 354
#define KW_SIZEOF 355
#define KW_STATIC 356
#define KW_STATIC_ASSERT 357
#define KW_STATIC_CAST 358
#define KW_STRUCT 359
#define KW_TEMPLATE 360
#define KW_THREAD_LOCAL 361
#define KW_THROW 362
#define KW_TRUE 363
#define KW_TRY 364
#define KW_TYPEDEF 365
#define KW_TYPEID 366
#define KW_TYPENAME 367
#define KW_UNION 368
#define KW_UNSIGNED 369
#define KW_USING 370
#define KW_VIRTUAL 371
#define KW_VOID 372
#define KW_VOLATILE 373
#define KW_WCHAR_T 374
#define KW_WHILE 375
#define START_CPP 376
#define START_CONST_EXPR 377
#define START_TYPE 378
#define KW_MAKE_MAP_PROPERTY 337
#define KW_MAKE_PROPERTY 338
#define KW_MAKE_PROPERTY2 339
#define KW_MAKE_SEQ 340
#define KW_MAKE_SEQ_PROPERTY 341
#define KW_MUTABLE 342
#define KW_NAMESPACE 343
#define KW_NEW 344
#define KW_NOEXCEPT 345
#define KW_NULLPTR 346
#define KW_OPERATOR 347
#define KW_OVERRIDE 348
#define KW_PRIVATE 349
#define KW_PROTECTED 350
#define KW_PUBLIC 351
#define KW_REGISTER 352
#define KW_REINTERPRET_CAST 353
#define KW_RETURN 354
#define KW_SHORT 355
#define KW_SIGNED 356
#define KW_SIZEOF 357
#define KW_STATIC 358
#define KW_STATIC_ASSERT 359
#define KW_STATIC_CAST 360
#define KW_STRUCT 361
#define KW_TEMPLATE 362
#define KW_THREAD_LOCAL 363
#define KW_THROW 364
#define KW_TRUE 365
#define KW_TRY 366
#define KW_TYPEDEF 367
#define KW_TYPEID 368
#define KW_TYPENAME 369
#define KW_UNION 370
#define KW_UNSIGNED 371
#define KW_USING 372
#define KW_VIRTUAL 373
#define KW_VOID 374
#define KW_VOLATILE 375
#define KW_WCHAR_T 376
#define KW_WHILE 377
#define START_CPP 378
#define START_CONST_EXPR 379
#define START_TYPE 380
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
/* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
typedef struct YYLTYPE YYLTYPE;
struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int cppyyparse (void *YYPARSE_PARAM);
#else
int cppyyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int cppyyparse (void);
#else
int cppyyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_CPPYY_BUILT_TMP_CPPBISON_YXX_H_INCLUDED */

View File

@ -284,9 +284,11 @@ pop_struct() {
%token KW_INLINE
%token KW_INT
%token KW_LONG
%token KW_MAKE_MAP_PROPERTY
%token KW_MAKE_PROPERTY
%token KW_MAKE_PROPERTY2
%token KW_MAKE_SEQ
%token KW_MAKE_SEQ_PROPERTY
%token KW_MUTABLE
%token KW_NAMESPACE
%token KW_NEW
@ -550,6 +552,118 @@ declaration:
setter_func, current_scope, @1.file);
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
}
}
| KW_MAKE_PROPERTY '(' name ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';'
{
CPPDeclaration *getter = $5->find_symbol(current_scope, global_scope, current_lexer);
if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("Reference to non-existent or invalid getter: " + $5->get_fully_scoped_name(), @5);
} else {
CPPDeclaration *setter = $7->find_symbol(current_scope, global_scope, current_lexer);
CPPFunctionGroup *setter_func = NULL;
if (setter == (CPPDeclaration *)NULL || setter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("Reference to non-existent or invalid setter: " + $7->get_fully_scoped_name(), @7);
} else {
setter_func = setter->as_function_group();
}
CPPDeclaration *deleter = $9->find_symbol(current_scope, global_scope, current_lexer);
if (deleter == (CPPDeclaration *)NULL || deleter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("reference to non-existent or invalid delete method: " + $9->get_fully_scoped_name(), @9);
deleter = NULL;
}
CPPMakeProperty *make_property = new CPPMakeProperty($3, getter->as_function_group(),
setter_func, current_scope, @1.file);
if (deleter) {
make_property->_del_function = deleter->as_function_group();
}
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
}
}
| KW_MAKE_SEQ_PROPERTY '(' name ',' IDENTIFIER ',' IDENTIFIER ')' ';'
{
CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer);
if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5);
length_getter = NULL;
}
CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer);
if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("Reference to non-existent or invalid getter: " + $7->get_fully_scoped_name(), @7);
}
CPPMakeProperty *make_property = new CPPMakeProperty($3, getter->as_function_group(), NULL, current_scope, @1.file);
make_property->_length_function = length_getter->as_function_group();
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
}
| KW_MAKE_SEQ_PROPERTY '(' name ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';'
{
CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer);
if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5);
length_getter = NULL;
}
CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer);
if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("Reference to non-existent or invalid getter: " + $7->get_fully_scoped_name(), @7);
} else {
CPPDeclaration *setter = $9->find_symbol(current_scope, global_scope, current_lexer);
CPPFunctionGroup *setter_func = NULL;
if (setter == (CPPDeclaration *)NULL || setter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("Reference to non-existent or invalid setter: " + $9->get_fully_scoped_name(), @9);
} else {
setter_func = setter->as_function_group();
}
CPPMakeProperty *make_property = new CPPMakeProperty($3, getter->as_function_group(),
setter_func, current_scope, @1.file);
make_property->_length_function = length_getter->as_function_group();
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
}
}
| KW_MAKE_SEQ_PROPERTY '(' name ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';'
{
CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer);
if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5);
length_getter = NULL;
}
CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer);
if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("Reference to non-existent or invalid getter: " + $7->get_fully_scoped_name(), @7);
} else {
CPPDeclaration *setter = $9->find_symbol(current_scope, global_scope, current_lexer);
CPPFunctionGroup *setter_func = NULL;
if (setter == (CPPDeclaration *)NULL || setter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("Reference to non-existent or invalid setter: " + $9->get_fully_scoped_name(), @9);
} else {
setter_func = setter->as_function_group();
}
CPPDeclaration *deleter = $11->find_symbol(current_scope, global_scope, current_lexer);
if (deleter == (CPPDeclaration *)NULL || deleter->get_subtype() != CPPDeclaration::ST_function_group) {
yyerror("reference to non-existent or invalid delete method: " + $11->get_fully_scoped_name(), @11);
deleter = NULL;
}
CPPMakeProperty *make_property = new CPPMakeProperty($3, getter->as_function_group(),
setter_func, current_scope, @1.file);
make_property->_length_function = length_getter->as_function_group();
if (deleter) {
make_property->_del_function = deleter->as_function_group();
}
current_scope->add_declaration(make_property, global_scope, current_lexer, @1);
}
}
| KW_MAKE_PROPERTY2 '(' name ',' IDENTIFIER ',' IDENTIFIER ')' ';'
{
@ -2349,21 +2463,23 @@ enum:
;
enum_decl:
enum_keyword name_no_final ':' enum_element_type
enum_keyword ':' enum_element_type
{
current_enum = new CPPEnumType($2, $4, current_scope, @1.file);
}
| enum_keyword name_no_final
{
current_enum = new CPPEnumType($2, current_scope, @1.file);
}
| enum_keyword ':' enum_element_type
{
current_enum = new CPPEnumType(NULL, $3, current_scope, @1.file);
current_enum = new CPPEnumType($1, NULL, $3, current_scope, NULL, @1.file);
}
| enum_keyword
{
current_enum = new CPPEnumType(NULL, current_scope, @1.file);
current_enum = new CPPEnumType($1, NULL, current_scope, NULL, @1.file);
}
| enum_keyword name_no_final ':' enum_element_type
{
CPPScope *new_scope = new CPPScope(current_scope, $2->_names.back(), V_public);
current_enum = new CPPEnumType($1, $2, $4, current_scope, new_scope, @1.file);
}
| enum_keyword name_no_final
{
CPPScope *new_scope = new CPPScope(current_scope, $2->_names.back(), V_public);
current_enum = new CPPEnumType($1, $2, current_scope, new_scope, @1.file);
}
;
@ -2383,14 +2499,12 @@ enum_body_trailing_comma:
| enum_body_trailing_comma name ','
{
assert(current_enum != NULL);
CPPInstance *inst = current_enum->add_element($2->get_simple_name());
current_scope->add_enum_value(inst, current_lexer, @2);
current_enum->add_element($2->get_simple_name(), NULL, current_lexer, @2);
}
| enum_body_trailing_comma name '=' const_expr ','
{
assert(current_enum != NULL);
CPPInstance *inst = current_enum->add_element($2->get_simple_name(), $4);
current_scope->add_enum_value(inst, current_lexer, @2);
current_enum->add_element($2->get_simple_name(), $4, current_lexer, @2);
};
enum_body:
@ -2398,14 +2512,12 @@ enum_body:
| enum_body_trailing_comma name
{
assert(current_enum != NULL);
CPPInstance *inst = current_enum->add_element($2->get_simple_name());
current_scope->add_enum_value(inst, current_lexer, @2);
current_enum->add_element($2->get_simple_name(), NULL, current_lexer, @2);
}
| enum_body_trailing_comma name '=' const_expr
{
assert(current_enum != NULL);
CPPInstance *inst = current_enum->add_element($2->get_simple_name(), $4);
current_scope->add_enum_value(inst, current_lexer, @2);
current_enum->add_element($2->get_simple_name(), $4, current_lexer, @2);
}
;
@ -2413,6 +2525,14 @@ enum_keyword:
KW_ENUM
{
$$ = CPPExtensionType::T_enum;
}
| KW_ENUM KW_CLASS
{
$$ = CPPExtensionType::T_enum_class;
}
| KW_ENUM KW_STRUCT
{
$$ = CPPExtensionType::T_enum_struct;
}
;
@ -3495,6 +3615,28 @@ name:
| KW_OVERRIDE
{
$$ = new CPPIdentifier("override", @1);
}
| KW_SIGNED
{
// This is not a keyword in Python, so it is useful to be able to use this
// in MAKE_PROPERTY definitions, etc.
$$ = new CPPIdentifier("signed", @1);
}
| KW_FLOAT
{
$$ = new CPPIdentifier("float", @1);
}
| KW_PUBLIC
{
$$ = new CPPIdentifier("public", @1);
}
| KW_PRIVATE
{
$$ = new CPPIdentifier("private", @1);
}
| KW_STATIC
{
$$ = new CPPIdentifier("static", @1);
}
;

View File

@ -22,42 +22,53 @@
#include "indent.h"
/**
* Creates an untyped, unscoped enum.
* Creates an untyped enum.
*/
CPPEnumType::
CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope,
const CPPFile &file) :
CPPExtensionType(T_enum, ident, current_scope, file),
_parent_scope(current_scope),
CPPEnumType(Type type, CPPIdentifier *ident, CPPScope *current_scope,
CPPScope *scope, const CPPFile &file) :
CPPExtensionType(type, ident, current_scope, file),
_scope(scope),
_element_type(NULL),
_last_value(NULL)
{
_parent_scope = (type == T_enum) ? current_scope : scope;
if (ident != NULL) {
ident->_native_scope = current_scope;
}
}
/**
* Creates a typed but unscoped enum.
* Creates a typed enum.
*/
CPPEnumType::
CPPEnumType(CPPIdentifier *ident, CPPType *element_type,
CPPScope *current_scope, const CPPFile &file) :
CPPExtensionType(T_enum, ident, current_scope, file),
_parent_scope(current_scope),
CPPEnumType(Type type, CPPIdentifier *ident, CPPType *element_type,
CPPScope *current_scope, CPPScope *scope, const CPPFile &file) :
CPPExtensionType(type, ident, current_scope, file),
_scope(scope),
_element_type(element_type),
_last_value(NULL)
{
_parent_scope = (type == T_enum) ? current_scope : scope;
if (ident != NULL) {
ident->_native_scope = current_scope;
}
}
/**
* Returns true if this is a scoped enum.
*/
bool CPPEnumType::
is_scoped() const {
return (_type != T_enum);
}
/**
* Returns the integral type used to store enum values.
*/
CPPType *CPPEnumType::
get_element_type() {
get_underlying_type() {
if (_element_type == NULL) {
// This enum is untyped. Use a suitable default, ie. 'int'. In the
// future, we might want to check whether it fits in an int.
@ -78,11 +89,18 @@ get_element_type() {
*
*/
CPPInstance *CPPEnumType::
add_element(const string &name, CPPExpression *value) {
add_element(const string &name, CPPExpression *value, CPPPreprocessor *preprocessor, const cppyyltype &pos) {
CPPIdentifier *ident = new CPPIdentifier(name);
ident->_native_scope = _parent_scope;
CPPInstance *inst = new CPPInstance(get_element_type(), ident);
CPPInstance *inst;
if (_type == T_enum) {
// Weakly typed enum.
inst = new CPPInstance(get_underlying_type(), ident);
} else {
// C++11-style strongly typed enum.
inst = new CPPInstance(this, ident);
}
inst->_storage_class |= CPPInstance::SC_constexpr;
_elements.push_back(inst);
@ -104,6 +122,41 @@ add_element(const string &name, CPPExpression *value) {
}
inst->_initializer = value;
_last_value = value;
if (preprocessor != (CPPPreprocessor *)NULL) {
// Same-line comment?
CPPCommentBlock *comment =
preprocessor->get_comment_on(pos.first_line, pos.file);
if (comment == (CPPCommentBlock *)NULL) {
// Nope. Check for a comment before this line.
comment =
preprocessor->get_comment_before(pos.first_line, pos.file);
if (comment != NULL) {
// This is a bit of a hack, but it prevents us from picking up a same-
// line comment from the previous line.
if (comment->_line_number != pos.first_line - 1 ||
comment->_col_number <= pos.first_column) {
inst->_leading_comment = comment;
}
}
} else {
inst->_leading_comment = comment;
}
}
// Add the value to the enum scope (as per C++11), assuming it's not anonymous.
if (_scope != NULL) {
_scope->add_enum_value(inst);
}
// Now add it to the containing scope as well if it's not an "enum class".
if (!is_scoped() && _parent_scope != NULL) {
_parent_scope->add_enum_value(inst);
}
return inst;
}

View File

@ -30,15 +30,16 @@ class CPPScope;
*/
class CPPEnumType : public CPPExtensionType {
public:
CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope,
const CPPFile &file);
CPPEnumType(CPPIdentifier *ident, CPPType *element_type,
CPPScope *current_scope, const CPPFile &file);
CPPEnumType(Type type, CPPIdentifier *ident, CPPScope *current_scope,
CPPScope *scope, const CPPFile &file);
CPPEnumType(Type type, CPPIdentifier *ident, CPPType *element_type,
CPPScope *current_scope, CPPScope *scope, const CPPFile &file);
CPPType *get_element_type();
bool is_scoped() const;
CPPType *get_underlying_type();
CPPInstance *add_element(const string &name,
CPPExpression *value = (CPPExpression *)NULL);
CPPInstance *add_element(const string &name, CPPExpression *value,
CPPPreprocessor *preprocessor, const cppyyltype &pos);
virtual bool is_incomplete() const;
@ -54,6 +55,7 @@ public:
virtual CPPEnumType *as_enum_type();
CPPScope *_parent_scope;
CPPScope *_scope;
CPPType *_element_type;
typedef vector<CPPInstance *> Elements;

View File

@ -949,7 +949,7 @@ determine_type() const {
case CPPDeclaration::ST_enum:
// Convert into integral type.
return t1->as_enum_type()->get_element_type();
return t1->as_enum_type()->get_underlying_type();
case CPPDeclaration::ST_simple:
{

View File

@ -229,6 +229,12 @@ operator << (ostream &out, CPPExtensionType::Type type) {
case CPPExtensionType::T_union:
return out << "union";
case CPPExtensionType::T_enum_class:
return out << "enum class";
case CPPExtensionType::T_enum_struct:
return out << "enum struct";
default:
return out << "***invalid extension type***";
}

View File

@ -34,6 +34,8 @@ public:
T_class,
T_struct,
T_union,
T_enum_class,
T_enum_struct,
};
CPPExtensionType(Type type, CPPIdentifier *ident, CPPScope *current_scope,

View File

@ -23,10 +23,12 @@ CPPMakeProperty(CPPIdentifier *ident,
CPPScope *current_scope, const CPPFile &file) :
CPPDeclaration(file),
_ident(ident),
_length_function(NULL),
_has_function(NULL),
_get_function(getter),
_set_function(setter),
_clear_function(NULL)
_clear_function(NULL),
_del_function(NULL)
{
_ident->_native_scope = current_scope;
}
@ -41,10 +43,12 @@ CPPMakeProperty(CPPIdentifier *ident,
CPPScope *current_scope, const CPPFile &file) :
CPPDeclaration(file),
_ident(ident),
_length_function(NULL),
_has_function(hasser),
_get_function(getter),
_set_function(setter),
_clear_function(clearer)
_clear_function(clearer),
_del_function(NULL)
{
_ident->_native_scope = current_scope;
}
@ -78,7 +82,11 @@ get_fully_scoped_name() const {
*/
void CPPMakeProperty::
output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
out << "__make_property";
if (_length_function != NULL) {
out << "__make_seq_property";
} else {
out << "__make_property";
}
if (_has_function != NULL) {
out.put('2');
@ -86,6 +94,10 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
out << "(" << _ident->get_local_name(scope);
if (_length_function != NULL) {
out << ", " << _length_function->_name;
}
if (_has_function != NULL) {
out << ", " << _has_function->_name;
}
@ -100,6 +112,10 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
out << ", " << _clear_function->_name;
}
if (_del_function != NULL) {
out << ", " << _del_function->_name;
}
out << ");";
}

View File

@ -46,10 +46,14 @@ public:
virtual CPPMakeProperty *as_make_property();
CPPIdentifier *_ident;
// If length_function is not NULL, this is actually a sequence property,
// and the other functions take an additional index argument.
CPPFunctionGroup *_length_function;
CPPFunctionGroup *_has_function;
CPPFunctionGroup *_get_function;
CPPFunctionGroup *_set_function;
CPPFunctionGroup *_clear_function;
CPPFunctionGroup *_del_function;
};
#endif

View File

@ -2458,9 +2458,11 @@ check_keyword(const string &name) {
if (name == "__inline__") return KW_INLINE;
if (name == "int") return KW_INT;
if (name == "long") return KW_LONG;
if (name == "__make_map_property") return KW_MAKE_MAP_PROPERTY;
if (name == "__make_property") return KW_MAKE_PROPERTY;
if (name == "__make_property2") return KW_MAKE_PROPERTY2;
if (name == "__make_seq") return KW_MAKE_SEQ;
if (name == "__make_seq_property") return KW_MAKE_SEQ_PROPERTY;
if (name == "mutable") return KW_MUTABLE;
if (name == "namespace") return KW_NAMESPACE;
if (name == "noexcept") return KW_NOEXCEPT;

View File

@ -124,34 +124,9 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope,
*
*/
void CPPScope::
add_enum_value(CPPInstance *inst, CPPPreprocessor *preprocessor,
const cppyyltype &pos) {
add_enum_value(CPPInstance *inst) {
inst->_vis = _current_vis;
if (inst->_leading_comment == (CPPCommentBlock *)NULL) {
// Same-line comment?
CPPCommentBlock *comment =
preprocessor->get_comment_on(pos.first_line, pos.file);
if (comment == (CPPCommentBlock *)NULL) {
// Nope. Check for a comment before this line.
comment =
preprocessor->get_comment_before(pos.first_line, pos.file);
if (comment != NULL) {
// This is a bit of a hack, but it prevents us from picking up a same-
// line comment from the previous line.
if (comment->_line_number != pos.first_line - 1 ||
comment->_col_number <= pos.first_column) {
inst->_leading_comment = comment;
}
}
} else {
inst->_leading_comment = comment;
}
}
string name = inst->get_simple_name();
if (!name.empty()) {
_enum_values[name] = inst;
@ -183,6 +158,8 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) {
break;
case CPPExtensionType::T_enum:
case CPPExtensionType::T_enum_struct:
case CPPExtensionType::T_enum_class:
_enums[name] = type;
break;
}
@ -606,6 +583,11 @@ find_scope(const string &name, bool recurse) const {
if (st != NULL) {
return st->_scope;
}
CPPEnumType *et = type->as_enum_type();
if (et != NULL) {
return et->_scope;
}
}
Using::const_iterator ui;
@ -645,11 +627,16 @@ find_scope(const string &name, CPPDeclaration::SubstDecl &subst,
}
CPPStructType *st = type->as_struct_type();
if (st == NULL) {
return NULL;
if (st != NULL) {
return st->_scope;
}
return st->_scope;
CPPEnumType *et = type->as_enum_type();
if (et != NULL) {
return et->_scope;
}
return NULL;
}
/**

View File

@ -61,9 +61,7 @@ public:
virtual void add_declaration(CPPDeclaration *decl, CPPScope *global_scope,
CPPPreprocessor *preprocessor,
const cppyyltype &pos);
virtual void add_enum_value(CPPInstance *inst,
CPPPreprocessor *preprocessor,
const cppyyltype &pos);
virtual void add_enum_value(CPPInstance *inst);
virtual void define_extension_type(CPPExtensionType *type,
CPPPreprocessor *error_sink = NULL);
virtual void define_namespace(CPPNamespace *scope);

View File

@ -43,11 +43,10 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope,
*
*/
void CPPTemplateScope::
add_enum_value(CPPInstance *inst, CPPPreprocessor *preprocessor,
const cppyyltype &pos) {
add_enum_value(CPPInstance *inst) {
inst->_template_scope = this;
assert(_parent_scope != NULL);
_parent_scope->add_enum_value(inst, preprocessor, pos);
_parent_scope->add_enum_value(inst);
}
/**

View File

@ -33,9 +33,7 @@ public:
virtual void add_declaration(CPPDeclaration *decl, CPPScope *global_scope,
CPPPreprocessor *preprocessor,
const cppyyltype &pos);
virtual void add_enum_value(CPPInstance *inst,
CPPPreprocessor *preprocessor,
const cppyyltype &pos);
virtual void add_enum_value(CPPInstance *inst);
virtual void define_extension_type(CPPExtensionType *type,
CPPPreprocessor *error_sink = NULL);
virtual void define_namespace(CPPNamespace *scope);

View File

@ -15,8 +15,8 @@
* Adds a linear sequence of uint32 words to the hash.
*/
INLINE size_t AddHash::
add_hash(size_t start, const PN_uint32 *words, size_t num_words) {
return (size_t)hashword(words, num_words, (PN_uint32)start);
add_hash(size_t start, const uint32_t *words, size_t num_words) {
return (size_t)hashword(words, num_words, (uint32_t)start);
}
/**
@ -24,7 +24,7 @@ add_hash(size_t start, const PN_uint32 *words, size_t num_words) {
*/
INLINE size_t AddHash::
add_hash(size_t start, const PN_float32 *floats, size_t num_floats) {
return add_hash(start, (const PN_uint32 *)floats, num_floats);
return add_hash(start, (const uint32_t *)floats, num_floats);
}
/**
@ -32,5 +32,5 @@ add_hash(size_t start, const PN_float32 *floats, size_t num_floats) {
*/
INLINE size_t AddHash::
add_hash(size_t start, const PN_float64 *floats, size_t num_floats) {
return add_hash(start, (const PN_uint32 *)floats, num_floats * 2);
return add_hash(start, (const uint32_t *)floats, num_floats * 2);
}

View File

@ -17,33 +17,33 @@
* Adds a linear sequence of bytes to the hash.
*/
size_t AddHash::
add_hash(size_t start, const PN_uint8 *bytes, size_t num_bytes) {
add_hash(size_t start, const uint8_t *bytes, size_t num_bytes) {
size_t num_words = num_bytes >> 2;
size_t remaining_bytes = num_bytes - (num_words << 2);
size_t hash = (size_t)hashword((const PN_uint32 *)bytes, num_words, (PN_uint32)start);
size_t hash = (size_t)hashword((const uint32_t *)bytes, num_words, (uint32_t)start);
switch (remaining_bytes) {
case 3:
{
PN_uint32 remaining;
uint32_t remaining;
remaining = (bytes[num_bytes - 3] << 16) | (bytes[num_bytes - 2] << 8) | (bytes[num_bytes - 1]);
hash = (size_t)hashword(&remaining, 1, (PN_uint32)hash);
hash = (size_t)hashword(&remaining, 1, (uint32_t)hash);
}
break;
case 2:
{
PN_uint32 remaining;
uint32_t remaining;
remaining = (bytes[num_bytes - 2] << 8) | (bytes[num_bytes - 1]);
hash = (size_t)hashword(&remaining, 1, (PN_uint32)hash);
hash = (size_t)hashword(&remaining, 1, (uint32_t)hash);
}
break;
case 1:
{
PN_uint32 remaining;
uint32_t remaining;
remaining = (bytes[num_bytes - 1]);
hash = (size_t)hashword(&remaining, 1, (PN_uint32)hash);
hash = (size_t)hashword(&remaining, 1, (uint32_t)hash);
}
break;

View File

@ -25,8 +25,8 @@
*/
class EXPCL_DTOOL AddHash {
public:
INLINE static size_t add_hash(size_t start, const PN_uint32 *words, size_t num_words);
static size_t add_hash(size_t start, const PN_uint8 *bytes, size_t num_bytes);
INLINE static size_t add_hash(size_t start, const uint32_t *words, size_t num_words);
static size_t add_hash(size_t start, const uint8_t *bytes, size_t num_bytes);
INLINE static size_t add_hash(size_t start, const PN_float32 *floats, size_t num_floats);
INLINE static size_t add_hash(size_t start, const PN_float64 *floats, size_t num_floats);
};

View File

@ -28,7 +28,7 @@
*/
class EXPCL_DTOOL AtomicAdjustI386Impl {
public:
typedef ALIGN_4BYTE PN_int32 Integer;
typedef ALIGN_4BYTE int32_t Integer;
typedef void *UnalignedPointer;
typedef ALIGN_4BYTE UnalignedPointer Pointer;

View File

@ -415,6 +415,7 @@ typedef struct _object PyObject;
#define MAKE_PROPERTY(property_name, ...) __make_property(property_name, __VA_ARGS__)
#define MAKE_PROPERTY2(property_name, ...) __make_property2(property_name, __VA_ARGS__)
#define MAKE_SEQ(seq_name, num_name, element_name) __make_seq(seq_name, num_name, element_name)
#define MAKE_SEQ_PROPERTY(property_name, ...) __make_seq_property(property_name, __VA_ARGS__)
#undef USE_STL_ALLOCATOR /* Don't try to parse these template classes in interrogate. */
#define EXTENSION(x) __extension x
#define EXTEND __extension
@ -425,6 +426,7 @@ typedef struct _object PyObject;
#define MAKE_PROPERTY(property_name, ...)
#define MAKE_PROPERTY2(property_name, ...)
#define MAKE_SEQ(seq_name, num_name, element_name)
#define MAKE_SEQ_PROPERTY(property_name, ...)
#define EXTENSION(x)
#define EXTEND
#endif

View File

@ -149,25 +149,25 @@ and these came close:
/*
--------------------------------------------------------------------
This works on all machines. To be useful, it requires
-- that the key be an array of PN_uint32's, and
-- that the length be the number of PN_uint32's in the key
-- that the key be an array of uint32_t's, and
-- that the length be the number of uint32_t's in the key
The function hashword() is identical to hashlittle() on little-endian
machines, and identical to hashbig() on big-endian machines,
except that the length has to be measured in PN_uint32s rather than in
except that the length has to be measured in uint32_ts rather than in
bytes. hashlittle() is more complicated than hashword() only because
hashlittle() has to dance around fitting the key bytes into registers.
--------------------------------------------------------------------
*/
PN_uint32 hashword(
const PN_uint32 *k, /* the key, an array of PN_uint32 values */
size_t length, /* the length of the key, in PN_uint32s */
PN_uint32 initval) /* the previous hash, or an arbitrary value */
uint32_t hashword(
const uint32_t *k, /* the key, an array of uint32_t values */
size_t length, /* the length of the key, in uint32_ts */
uint32_t initval) /* the previous hash, or an arbitrary value */
{
PN_uint32 a,b,c;
uint32_t a,b,c;
/* Set up the internal state */
a = b = c = 0xdeadbeef + (((PN_uint32)length)<<2) + initval;
a = b = c = 0xdeadbeef + (((uint32_t)length)<<2) + initval;
/*------------------------------------------------- handle most of the key */
while (length > 3)
@ -180,7 +180,7 @@ PN_uint32 initval) /* the previous hash, or an arbitrary value */
k += 3;
}
/*------------------------------------------- handle the last 3 PN_uint32's */
/*------------------------------------------- handle the last 3 uint32_t's */
switch(length) /* all the case statements fall through */
{
case 3 : c+=k[2];
@ -211,7 +211,7 @@ use a bitmask. For example, if you need only 10 bits, do
h = (h & hashmask(10));
In which case, the hash table should have hashsize(10) elements.
If you are hashing n strings (PN_uint8 **)k, do it like this:
If you are hashing n strings (uint8_t **)k, do it like this:
for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
By Bob Jenkins, 2006. bob_jenkins@burtleburtle.net. You may use this
@ -222,19 +222,19 @@ acceptable. Do NOT use for cryptographic purposes.
-------------------------------------------------------------------------------
*/
PN_uint32 hashlittle( const void *key, size_t length, PN_uint32 initval)
uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
{
PN_uint32 a,b,c; /* internal state */
uint32_t a,b,c; /* internal state */
union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
/* Set up the internal state */
a = b = c = 0xdeadbeef + ((PN_uint32)length) + initval;
a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
u.ptr = key;
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
const PN_uint32 *k =(PN_uint32*) key; /* read 32-bit chunks */
const uint32_t *k =(uint32_t*) key; /* read 32-bit chunks */
#ifdef VALGRIND
const PN_uint8 *k8;
const uint8_t *k8;
#endif
/*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
@ -279,20 +279,20 @@ PN_uint32 hashlittle( const void *key, size_t length, PN_uint32 initval)
#else /* make valgrind happy */
k8 = (const PN_uint8 *)k;
k8 = (const uint8_t *)k;
switch(length)
{
case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
case 11: c+=((PN_uint32)k8[10])<<16; /* fall through */
case 10: c+=((PN_uint32)k8[9])<<8; /* fall through */
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
case 9 : c+=k8[8]; /* fall through */
case 8 : b+=k[1]; a+=k[0]; break;
case 7 : b+=((PN_uint32)k8[6])<<16; /* fall through */
case 6 : b+=((PN_uint32)k8[5])<<8; /* fall through */
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
case 5 : b+=k8[4]; /* fall through */
case 4 : a+=k[0]; break;
case 3 : a+=((PN_uint32)k8[2])<<16; /* fall through */
case 2 : a+=((PN_uint32)k8[1])<<8; /* fall through */
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
case 1 : a+=k8[0]; break;
case 0 : return c;
}
@ -300,45 +300,45 @@ PN_uint32 hashlittle( const void *key, size_t length, PN_uint32 initval)
#endif /* !valgrind */
} else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
const PN_uint16 *k = (PN_uint16*)key; /* read 16-bit chunks */
const PN_uint8 *k8;
const uint16_t *k = (uint16_t*)key; /* read 16-bit chunks */
const uint8_t *k8;
/*--------------- all but last block: aligned reads and different mixing */
while (length > 12)
{
a += k[0] + (((PN_uint32)k[1])<<16);
b += k[2] + (((PN_uint32)k[3])<<16);
c += k[4] + (((PN_uint32)k[5])<<16);
a += k[0] + (((uint32_t)k[1])<<16);
b += k[2] + (((uint32_t)k[3])<<16);
c += k[4] + (((uint32_t)k[5])<<16);
mix(a,b,c);
length -= 12;
k += 6;
}
/*----------------------------- handle the last (probably partial) block */
k8 = (const PN_uint8 *)k;
k8 = (const uint8_t *)k;
switch(length)
{
case 12: c+=k[4]+(((PN_uint32)k[5])<<16);
b+=k[2]+(((PN_uint32)k[3])<<16);
a+=k[0]+(((PN_uint32)k[1])<<16);
case 12: c+=k[4]+(((uint32_t)k[5])<<16);
b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 11: c+=((PN_uint32)k8[10])<<16; /* fall through */
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
case 10: c+=k[4];
b+=k[2]+(((PN_uint32)k[3])<<16);
a+=k[0]+(((PN_uint32)k[1])<<16);
b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 9 : c+=k8[8]; /* fall through */
case 8 : b+=k[2]+(((PN_uint32)k[3])<<16);
a+=k[0]+(((PN_uint32)k[1])<<16);
case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 7 : b+=((PN_uint32)k8[6])<<16; /* fall through */
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
case 6 : b+=k[2];
a+=k[0]+(((PN_uint32)k[1])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 5 : b+=k8[4]; /* fall through */
case 4 : a+=k[0]+(((PN_uint32)k[1])<<16);
case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 3 : a+=((PN_uint32)k8[2])<<16; /* fall through */
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
case 2 : a+=k[0];
break;
case 1 : a+=k8[0];
@ -347,23 +347,23 @@ PN_uint32 hashlittle( const void *key, size_t length, PN_uint32 initval)
}
} else { /* need to read the key one byte at a time */
const PN_uint8 *k =(PN_uint8*) key;
const uint8_t *k =(uint8_t*) key;
/*--------------- all but the last block: affect some 32 bits of (a,b,c) */
while (length > 12)
{
a += k[0];
a += ((PN_uint32)k[1])<<8;
a += ((PN_uint32)k[2])<<16;
a += ((PN_uint32)k[3])<<24;
a += ((uint32_t)k[1])<<8;
a += ((uint32_t)k[2])<<16;
a += ((uint32_t)k[3])<<24;
b += k[4];
b += ((PN_uint32)k[5])<<8;
b += ((PN_uint32)k[6])<<16;
b += ((PN_uint32)k[7])<<24;
b += ((uint32_t)k[5])<<8;
b += ((uint32_t)k[6])<<16;
b += ((uint32_t)k[7])<<24;
c += k[8];
c += ((PN_uint32)k[9])<<8;
c += ((PN_uint32)k[10])<<16;
c += ((PN_uint32)k[11])<<24;
c += ((uint32_t)k[9])<<8;
c += ((uint32_t)k[10])<<16;
c += ((uint32_t)k[11])<<24;
mix(a,b,c);
length -= 12;
k += 12;
@ -372,17 +372,17 @@ PN_uint32 hashlittle( const void *key, size_t length, PN_uint32 initval)
/*-------------------------------- last block: affect all 32 bits of (c) */
switch(length) /* all the case statements fall through */
{
case 12: c+=((PN_uint32)k[11])<<24;
case 11: c+=((PN_uint32)k[10])<<16;
case 10: c+=((PN_uint32)k[9])<<8;
case 12: c+=((uint32_t)k[11])<<24;
case 11: c+=((uint32_t)k[10])<<16;
case 10: c+=((uint32_t)k[9])<<8;
case 9 : c+=k[8];
case 8 : b+=((PN_uint32)k[7])<<24;
case 7 : b+=((PN_uint32)k[6])<<16;
case 6 : b+=((PN_uint32)k[5])<<8;
case 8 : b+=((uint32_t)k[7])<<24;
case 7 : b+=((uint32_t)k[6])<<16;
case 6 : b+=((uint32_t)k[5])<<8;
case 5 : b+=k[4];
case 4 : a+=((PN_uint32)k[3])<<24;
case 3 : a+=((PN_uint32)k[2])<<16;
case 2 : a+=((PN_uint32)k[1])<<8;
case 4 : a+=((uint32_t)k[3])<<24;
case 3 : a+=((uint32_t)k[2])<<16;
case 2 : a+=((uint32_t)k[1])<<8;
case 1 : a+=k[0];
break;
case 0 : return c;
@ -407,21 +407,21 @@ PN_uint32 hashlittle( const void *key, size_t length, PN_uint32 initval)
void hashlittle2(
const void *key, /* the key to hash */
size_t length, /* length of the key */
PN_uint32 *pc, /* IN: primary initval, OUT: primary hash */
PN_uint32 *pb) /* IN: secondary initval, OUT: secondary hash */
uint32_t *pc, /* IN: primary initval, OUT: primary hash */
uint32_t *pb) /* IN: secondary initval, OUT: secondary hash */
{
PN_uint32 a,b,c; /* internal state */
uint32_t a,b,c; /* internal state */
union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */
/* Set up the internal state */
a = b = c = 0xdeadbeef + ((PN_uint32)length) + *pc;
a = b = c = 0xdeadbeef + ((uint32_t)length) + *pc;
c += *pb;
u.ptr = key;
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
const PN_uint32 *k = (PN_uint32*)key; /* read 32-bit chunks */
const uint32_t *k = (uint32_t*)key; /* read 32-bit chunks */
#ifdef VALGRIND
const PN_uint8 *k8;
const uint8_t *k8;
#endif
/*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
@ -466,20 +466,20 @@ void hashlittle2(
#else /* make valgrind happy */
k8 = (const PN_uint8 *)k;
k8 = (const uint8_t *)k;
switch(length)
{
case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
case 11: c+=((PN_uint32)k8[10])<<16; /* fall through */
case 10: c+=((PN_uint32)k8[9])<<8; /* fall through */
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
case 9 : c+=k8[8]; /* fall through */
case 8 : b+=k[1]; a+=k[0]; break;
case 7 : b+=((PN_uint32)k8[6])<<16; /* fall through */
case 6 : b+=((PN_uint32)k8[5])<<8; /* fall through */
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
case 5 : b+=k8[4]; /* fall through */
case 4 : a+=k[0]; break;
case 3 : a+=((PN_uint32)k8[2])<<16; /* fall through */
case 2 : a+=((PN_uint32)k8[1])<<8; /* fall through */
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
case 1 : a+=k8[0]; break;
case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */
}
@ -487,45 +487,45 @@ void hashlittle2(
#endif /* !valgrind */
} else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
const PN_uint16 *k = (PN_uint16*)key; /* read 16-bit chunks */
const PN_uint8 *k8;
const uint16_t *k = (uint16_t*)key; /* read 16-bit chunks */
const uint8_t *k8;
/*--------------- all but last block: aligned reads and different mixing */
while (length > 12)
{
a += k[0] + (((PN_uint32)k[1])<<16);
b += k[2] + (((PN_uint32)k[3])<<16);
c += k[4] + (((PN_uint32)k[5])<<16);
a += k[0] + (((uint32_t)k[1])<<16);
b += k[2] + (((uint32_t)k[3])<<16);
c += k[4] + (((uint32_t)k[5])<<16);
mix(a,b,c);
length -= 12;
k += 6;
}
/*----------------------------- handle the last (probably partial) block */
k8 = (const PN_uint8 *)k;
k8 = (const uint8_t *)k;
switch(length)
{
case 12: c+=k[4]+(((PN_uint32)k[5])<<16);
b+=k[2]+(((PN_uint32)k[3])<<16);
a+=k[0]+(((PN_uint32)k[1])<<16);
case 12: c+=k[4]+(((uint32_t)k[5])<<16);
b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 11: c+=((PN_uint32)k8[10])<<16; /* fall through */
case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
case 10: c+=k[4];
b+=k[2]+(((PN_uint32)k[3])<<16);
a+=k[0]+(((PN_uint32)k[1])<<16);
b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 9 : c+=k8[8]; /* fall through */
case 8 : b+=k[2]+(((PN_uint32)k[3])<<16);
a+=k[0]+(((PN_uint32)k[1])<<16);
case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 7 : b+=((PN_uint32)k8[6])<<16; /* fall through */
case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
case 6 : b+=k[2];
a+=k[0]+(((PN_uint32)k[1])<<16);
a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 5 : b+=k8[4]; /* fall through */
case 4 : a+=k[0]+(((PN_uint32)k[1])<<16);
case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
break;
case 3 : a+=((PN_uint32)k8[2])<<16; /* fall through */
case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
case 2 : a+=k[0];
break;
case 1 : a+=k8[0];
@ -534,23 +534,23 @@ void hashlittle2(
}
} else { /* need to read the key one byte at a time */
const PN_uint8 *k = (PN_uint8*)key;
const uint8_t *k = (uint8_t*)key;
/*--------------- all but the last block: affect some 32 bits of (a,b,c) */
while (length > 12)
{
a += k[0];
a += ((PN_uint32)k[1])<<8;
a += ((PN_uint32)k[2])<<16;
a += ((PN_uint32)k[3])<<24;
a += ((uint32_t)k[1])<<8;
a += ((uint32_t)k[2])<<16;
a += ((uint32_t)k[3])<<24;
b += k[4];
b += ((PN_uint32)k[5])<<8;
b += ((PN_uint32)k[6])<<16;
b += ((PN_uint32)k[7])<<24;
b += ((uint32_t)k[5])<<8;
b += ((uint32_t)k[6])<<16;
b += ((uint32_t)k[7])<<24;
c += k[8];
c += ((PN_uint32)k[9])<<8;
c += ((PN_uint32)k[10])<<16;
c += ((PN_uint32)k[11])<<24;
c += ((uint32_t)k[9])<<8;
c += ((uint32_t)k[10])<<16;
c += ((uint32_t)k[11])<<24;
mix(a,b,c);
length -= 12;
k += 12;
@ -559,17 +559,17 @@ void hashlittle2(
/*-------------------------------- last block: affect all 32 bits of (c) */
switch(length) /* all the case statements fall through */
{
case 12: c+=((PN_uint32)k[11])<<24;
case 11: c+=((PN_uint32)k[10])<<16;
case 10: c+=((PN_uint32)k[9])<<8;
case 12: c+=((uint32_t)k[11])<<24;
case 11: c+=((uint32_t)k[10])<<16;
case 10: c+=((uint32_t)k[9])<<8;
case 9 : c+=k[8];
case 8 : b+=((PN_uint32)k[7])<<24;
case 7 : b+=((PN_uint32)k[6])<<16;
case 6 : b+=((PN_uint32)k[5])<<8;
case 8 : b+=((uint32_t)k[7])<<24;
case 7 : b+=((uint32_t)k[6])<<16;
case 6 : b+=((uint32_t)k[5])<<8;
case 5 : b+=k[4];
case 4 : a+=((PN_uint32)k[3])<<24;
case 3 : a+=((PN_uint32)k[2])<<16;
case 2 : a+=((PN_uint32)k[1])<<8;
case 4 : a+=((uint32_t)k[3])<<24;
case 3 : a+=((uint32_t)k[2])<<16;
case 2 : a+=((uint32_t)k[1])<<8;
case 1 : a+=k[0];
break;
case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */
@ -588,19 +588,19 @@ void hashlittle2(
* from hashlittle() on all machines. hashbig() takes advantage of
* big-endian byte ordering.
*/
PN_uint32 hashbig( const void *key, size_t length, PN_uint32 initval)
uint32_t hashbig( const void *key, size_t length, uint32_t initval)
{
PN_uint32 a,b,c;
uint32_t a,b,c;
union { const void *ptr; size_t i; } u; /* to cast key to (size_t) happily */
/* Set up the internal state */
a = b = c = 0xdeadbeef + ((PN_uint32)length) + initval;
a = b = c = 0xdeadbeef + ((uint32_t)length) + initval;
u.ptr = key;
if (HASH_BIG_ENDIAN && ((u.i & 0x3) == 0)) {
const PN_uint32 *k = (PN_uint32*)key; /* read 32-bit chunks */
const uint32_t *k = (uint32_t*)key; /* read 32-bit chunks */
#ifdef VALGRIND
const PN_uint8 *k8;
const uint8_t *k8;
#endif
/*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
@ -645,44 +645,44 @@ PN_uint32 hashbig( const void *key, size_t length, PN_uint32 initval)
#else /* make valgrind happy */
k8 = (const PN_uint8 *)k;
k8 = (const uint8_t *)k;
switch(length) /* all the case statements fall through */
{
case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
case 11: c+=((PN_uint32)k8[10])<<8; /* fall through */
case 10: c+=((PN_uint32)k8[9])<<16; /* fall through */
case 9 : c+=((PN_uint32)k8[8])<<24; /* fall through */
case 11: c+=((uint32_t)k8[10])<<8; /* fall through */
case 10: c+=((uint32_t)k8[9])<<16; /* fall through */
case 9 : c+=((uint32_t)k8[8])<<24; /* fall through */
case 8 : b+=k[1]; a+=k[0]; break;
case 7 : b+=((PN_uint32)k8[6])<<8; /* fall through */
case 6 : b+=((PN_uint32)k8[5])<<16; /* fall through */
case 5 : b+=((PN_uint32)k8[4])<<24; /* fall through */
case 7 : b+=((uint32_t)k8[6])<<8; /* fall through */
case 6 : b+=((uint32_t)k8[5])<<16; /* fall through */
case 5 : b+=((uint32_t)k8[4])<<24; /* fall through */
case 4 : a+=k[0]; break;
case 3 : a+=((PN_uint32)k8[2])<<8; /* fall through */
case 2 : a+=((PN_uint32)k8[1])<<16; /* fall through */
case 1 : a+=((PN_uint32)k8[0])<<24; break;
case 3 : a+=((uint32_t)k8[2])<<8; /* fall through */
case 2 : a+=((uint32_t)k8[1])<<16; /* fall through */
case 1 : a+=((uint32_t)k8[0])<<24; break;
case 0 : return c;
}
#endif /* !VALGRIND */
} else { /* need to read the key one byte at a time */
const PN_uint8 *k = (PN_uint8*)key;
const uint8_t *k = (uint8_t*)key;
/*--------------- all but the last block: affect some 32 bits of (a,b,c) */
while (length > 12)
{
a += ((PN_uint32)k[0])<<24;
a += ((PN_uint32)k[1])<<16;
a += ((PN_uint32)k[2])<<8;
a += ((PN_uint32)k[3]);
b += ((PN_uint32)k[4])<<24;
b += ((PN_uint32)k[5])<<16;
b += ((PN_uint32)k[6])<<8;
b += ((PN_uint32)k[7]);
c += ((PN_uint32)k[8])<<24;
c += ((PN_uint32)k[9])<<16;
c += ((PN_uint32)k[10])<<8;
c += ((PN_uint32)k[11]);
a += ((uint32_t)k[0])<<24;
a += ((uint32_t)k[1])<<16;
a += ((uint32_t)k[2])<<8;
a += ((uint32_t)k[3]);
b += ((uint32_t)k[4])<<24;
b += ((uint32_t)k[5])<<16;
b += ((uint32_t)k[6])<<8;
b += ((uint32_t)k[7]);
c += ((uint32_t)k[8])<<24;
c += ((uint32_t)k[9])<<16;
c += ((uint32_t)k[10])<<8;
c += ((uint32_t)k[11]);
mix(a,b,c);
length -= 12;
k += 12;
@ -692,17 +692,17 @@ PN_uint32 hashbig( const void *key, size_t length, PN_uint32 initval)
switch(length) /* all the case statements fall through */
{
case 12: c+=k[11];
case 11: c+=((PN_uint32)k[10])<<8;
case 10: c+=((PN_uint32)k[9])<<16;
case 9 : c+=((PN_uint32)k[8])<<24;
case 11: c+=((uint32_t)k[10])<<8;
case 10: c+=((uint32_t)k[9])<<16;
case 9 : c+=((uint32_t)k[8])<<24;
case 8 : b+=k[7];
case 7 : b+=((PN_uint32)k[6])<<8;
case 6 : b+=((PN_uint32)k[5])<<16;
case 5 : b+=((PN_uint32)k[4])<<24;
case 7 : b+=((uint32_t)k[6])<<8;
case 6 : b+=((uint32_t)k[5])<<16;
case 5 : b+=((uint32_t)k[4])<<24;
case 4 : a+=k[3];
case 3 : a+=((PN_uint32)k[2])<<8;
case 2 : a+=((PN_uint32)k[1])<<16;
case 1 : a+=((PN_uint32)k[0])<<24;
case 3 : a+=((uint32_t)k[2])<<8;
case 2 : a+=((uint32_t)k[1])<<16;
case 1 : a+=((uint32_t)k[0])<<24;
break;
case 0 : return c;
}
@ -718,9 +718,9 @@ PN_uint32 hashbig( const void *key, size_t length, PN_uint32 initval)
/* used for timings */
void driver1()
{
PN_uint8 buf[256];
PN_uint32 i;
PN_uint32 h=0;
uint8_t buf[256];
uint32_t i;
uint32_t h=0;
time_t a,z;
time(&a);
@ -740,11 +740,11 @@ void driver1()
#define MAXLEN 70
void driver2()
{
PN_uint8 qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1];
PN_uint32 c[HASHSTATE], d[HASHSTATE], i=0, j=0, k, l, m=0, z;
PN_uint32 e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE];
PN_uint32 x[HASHSTATE],y[HASHSTATE];
PN_uint32 hlen;
uint8_t qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1];
uint32_t c[HASHSTATE], d[HASHSTATE], i=0, j=0, k, l, m=0, z;
uint32_t e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE];
uint32_t x[HASHSTATE],y[HASHSTATE];
uint32_t hlen;
printf("No more than %d trials should ever be needed \n",MAXPAIR/2);
for (hlen=0; hlen < MAXLEN; ++hlen)
@ -757,14 +757,14 @@ void driver2()
for (m=1; m<8; ++m) /*------------ for serveral possible initvals, */
{
for (l=0; l<HASHSTATE; ++l)
e[l]=f[l]=g[l]=h[l]=x[l]=y[l]=~((PN_uint32)0);
e[l]=f[l]=g[l]=h[l]=x[l]=y[l]=~((uint32_t)0);
/*---- check that every output bit is affected by that input bit */
for (k=0; k<MAXPAIR; k+=2)
{
PN_uint32 finished=1;
uint32_t finished=1;
/* keys have one bit different */
for (l=0; l<hlen+1; ++l) {a[l] = b[l] = (PN_uint8)0;}
for (l=0; l<hlen+1; ++l) {a[l] = b[l] = (uint8_t)0;}
/* have a and b be two keys differing in only one bit */
a[i] ^= (k<<j);
a[i] ^= (k>>(8-j));
@ -810,23 +810,23 @@ void driver2()
/* Check for reading beyond the end of the buffer and alignment problems */
void driver3()
{
PN_uint8 buf[MAXLEN+20], *b;
PN_uint32 len;
PN_uint8 q[] = "This is the time for all good men to come to the aid of their country...";
PN_uint32 h;
PN_uint8 qq[] = "xThis is the time for all good men to come to the aid of their country...";
PN_uint32 i;
PN_uint8 qqq[] = "xxThis is the time for all good men to come to the aid of their country...";
PN_uint32 j;
PN_uint8 qqqq[] = "xxxThis is the time for all good men to come to the aid of their country...";
PN_uint32 ref,x,y;
PN_uint8 *p;
uint8_t buf[MAXLEN+20], *b;
uint32_t len;
uint8_t q[] = "This is the time for all good men to come to the aid of their country...";
uint32_t h;
uint8_t qq[] = "xThis is the time for all good men to come to the aid of their country...";
uint32_t i;
uint8_t qqq[] = "xxThis is the time for all good men to come to the aid of their country...";
uint32_t j;
uint8_t qqqq[] = "xxxThis is the time for all good men to come to the aid of their country...";
uint32_t ref,x,y;
uint8_t *p;
printf("Endianness. These lines should all be the same (for values filled in):\n");
printf("%.8x %.8x %.8x\n",
hashword((const PN_uint32 *)q, (sizeof(q)-1)/4, 13),
hashword((const PN_uint32 *)q, (sizeof(q)-5)/4, 13),
hashword((const PN_uint32 *)q, (sizeof(q)-9)/4, 13));
hashword((const uint32_t *)q, (sizeof(q)-1)/4, 13),
hashword((const uint32_t *)q, (sizeof(q)-5)/4, 13),
hashword((const uint32_t *)q, (sizeof(q)-9)/4, 13));
p = q;
printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n",
hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13),
@ -868,11 +868,11 @@ void driver3()
for (j=0; j<i; ++j) *(b+j)=0;
/* these should all be equal */
ref = hashlittle(b, len, (PN_uint32)1);
*(b+i)=(PN_uint8)~0;
*(b-1)=(PN_uint8)~0;
x = hashlittle(b, len, (PN_uint32)1);
y = hashlittle(b, len, (PN_uint32)1);
ref = hashlittle(b, len, (uint32_t)1);
*(b+i)=(uint8_t)~0;
*(b-1)=(uint8_t)~0;
x = hashlittle(b, len, (uint32_t)1);
y = hashlittle(b, len, (uint32_t)1);
if ((ref != x) || (ref != y))
{
printf("alignment error: %.8x %.8x %.8x %d %d\n",ref,x,y,
@ -885,8 +885,8 @@ void driver3()
/* check for problems with nulls */
void driver4()
{
PN_uint8 buf[1];
PN_uint32 h,i,state[HASHSTATE];
uint8_t buf[1];
uint32_t h,i,state[HASHSTATE];
buf[0] = ~0;

View File

@ -21,9 +21,9 @@
extern "C" {
#endif
EXPCL_DTOOL PN_uint32 hashword(const PN_uint32 *k, /* the key, an array of PN_uint32 values */
size_t length, /* the length of the key, in PN_uint32s */
PN_uint32 initval);
EXPCL_DTOOL uint32_t hashword(const uint32_t *k, /* the key, an array of uint32_t values */
size_t length, /* the length of the key, in uint32_ts */
uint32_t initval);
#ifdef __cplusplus
}; /* end of extern "C" */

View File

@ -19,30 +19,7 @@
// This header file defines a number of typedefs that correspond to the
// various numeric types for unsigned and signed numbers of various widths.
#if defined(WIN32_VC) && !defined(CPPPARSER)
typedef signed __int8 PN_int8;
typedef signed __int16 PN_int16;
typedef signed __int32 PN_int32;
typedef signed __int64 PN_int64;
typedef unsigned __int8 PN_uint8;
typedef unsigned __int16 PN_uint16;
typedef unsigned __int32 PN_uint32;
typedef unsigned __int64 PN_uint64;
#else
typedef signed char PN_int8;
typedef short int PN_int16;
typedef int PN_int32;
typedef long long int PN_int64;
typedef unsigned char PN_uint8;
typedef unsigned short int PN_uint16;
typedef unsigned int PN_uint32;
typedef unsigned long long int PN_uint64;
#endif
#include <stdint.h>
typedef double PN_float64;
typedef float PN_float32;

View File

@ -99,7 +99,7 @@ is_equal(const Key &a, const Key &b) const {
template<class Key, class Compare>
INLINE size_t integer_hash<Key, Compare>::
add_hash(size_t hash, const Key &key) {
PN_uint32 key32 = (PN_uint32)(key);
uint32_t key32 = (uint32_t)(key);
return AddHash::add_hash(hash, &key32, 1);
}
@ -109,7 +109,7 @@ add_hash(size_t hash, const Key &key) {
INLINE size_t pointer_hash::
add_hash(size_t hash, const void *key) {
// We don't mind if this loses precision.
PN_uint32 key32 = (PN_uint32)reinterpret_cast<uintptr_t>(key);
uint32_t key32 = (uint32_t)reinterpret_cast<uintptr_t>(key);
return AddHash::add_hash(hash, &key32, 1);
}
@ -147,7 +147,7 @@ operator () (const Key &a, const Key &b) const {
template<class Key>
INLINE size_t floating_point_hash<Key>::
add_hash(size_t hash, const Key &key) const {
PN_uint32 key32 = (PN_uint32)(key / _threshold + 0.5f);
uint32_t key32 = (uint32_t)(key / _threshold + 0.5f);
return AddHash::add_hash(hash, &key32, 1);
}
@ -173,7 +173,7 @@ add_hash(size_t hash, const Key &key) {
}
#endif
size_t num_bytes = (key.size() * sizeof(key[0]));
return AddHash::add_hash(hash, (const PN_uint8 *)&key[0], num_bytes);
return AddHash::add_hash(hash, (const uint8_t *)&key[0], num_bytes);
}
/**

View File

@ -114,6 +114,8 @@ PUBLISHED:
MAKE_PROPERTY(index, get_index);
MAKE_PROPERTY(name, get_name);
MAKE_SEQ_PROPERTY(parent_classes, get_num_parent_classes, get_parent_class);
MAKE_SEQ_PROPERTY(child_classes, get_num_child_classes, get_child_class);
public:
INLINE static TypeHandle from_index(int index);

View File

@ -511,10 +511,10 @@ TypeRegistry() {
// Here's a few sanity checks on the sizes of our words. We have to put it
// here, at runtime, since there doesn't appear to be a cross-platform
// compile-time way to verify that we've chosen the right word sizes.
assert(sizeof(PN_uint8) == 1 && sizeof(PN_int8) == 1);
assert(sizeof(PN_uint16) == 2 && sizeof(PN_int16) == 2);
assert(sizeof(PN_uint32) == 4 && sizeof(PN_int32) == 4);
assert(sizeof(PN_uint64) == 8 && sizeof(PN_int64) == 8);
assert(sizeof(uint8_t) == 1 && sizeof(int8_t) == 1);
assert(sizeof(uint16_t) == 2 && sizeof(int16_t) == 2);
assert(sizeof(uint32_t) == 4 && sizeof(int32_t) == 4);
assert(sizeof(uint64_t) == 8 && sizeof(int64_t) == 8);
assert(sizeof(PN_float32) == 4);
assert(sizeof(PN_float64) == 8);

View File

@ -79,6 +79,9 @@ PUBLISHED:
// ptr() returns the pointer to the global TypeRegistry object.
static TypeRegistry *ptr();
MAKE_SEQ_PROPERTY(typehandles, get_num_typehandles, get_typehandle);
MAKE_SEQ_PROPERTY(root_classes, get_num_root_classes, get_root_class);
private:
// The TypeRegistry class should never be constructed by user code. There
// is only one in the universe, and it constructs itself!

View File

@ -71,6 +71,7 @@ PUBLISHED:
size_t get_num_directories() const;
const Filename &get_directory(size_t n) const;
MAKE_SEQ(get_directories, get_num_directories, get_directory);
MAKE_SEQ_PROPERTY(directories, get_num_directories, get_directory);
Filename find_file(const Filename &filename) const;
size_t find_all_files(const Filename &filename, Results &results) const;

View File

@ -50,6 +50,7 @@ PUBLISHED:
size_t get_num_systems() const;
string get_system(size_t n) const;
MAKE_SEQ(get_systems, get_num_systems, get_system);
MAKE_SEQ_PROPERTY(systems, get_num_systems, get_system);
string get_system_tag(const string &system, const string &tag) const;

View File

@ -80,13 +80,13 @@ format_string(int value) {
}
INLINE string
format_string(PN_int64 value) {
format_string(int64_t value) {
char buffer[21];
char *p = buffer + 20;
*p = 0;
if (value < 0) {
PN_uint64 posv = (PN_uint64)-value;
uint64_t posv = (uint64_t)-value;
do {
*--p = '0' + (posv % 10);
posv /= 10;

View File

@ -73,7 +73,7 @@ INLINE string format_string(float value);
INLINE string format_string(double value);
INLINE string format_string(unsigned int value);
INLINE string format_string(int value);
INLINE string format_string(PN_int64 value);
INLINE string format_string(int64_t value);
#include "string_utils.I"

View File

@ -86,10 +86,12 @@ MakeSeq(const string &name, const InterrogateMakeSeq &imake_seq) :
InterfaceMaker::Property::
Property(const InterrogateElement &ielement) :
_ielement(ielement),
_length_function(NULL),
_getter(NULL),
_setter(NULL),
_has_function(NULL),
_clear_function(NULL)
_clear_function(NULL),
_deleter(NULL)
{
}

View File

@ -126,10 +126,12 @@ public:
Property(const InterrogateElement &ielement);
const InterrogateElement &_ielement;
Function *_length_function;
Function *_getter;
Function *_setter;
Function *_has_function;
Function *_clear_function;
Function *_deleter;
};
typedef vector<Property *> Properties;

View File

@ -764,10 +764,6 @@ write_prototypes(ostream &out_code, ostream *out_h) {
*out_h << "#include \"py_panda.h\"\n\n";
}
out_code << "//********************************************************************\n";
out_code << "//*** prototypes for .. Global\n";
out_code << "//********************************************************************\n";
/*
for (fi = _functions.begin(); fi != _functions.end(); ++fi)
{
@ -792,9 +788,9 @@ write_prototypes(ostream &out_code, ostream *out_h) {
}
}
out_code << "//********************************************************************\n";
out_code << "//*** prototypes for .. External Objects\n";
out_code << "//********************************************************************\n";
out_code << "/**\n";
out_code << " * Extern declarations for imported classes\n";
out_code << " */\n";
for (std::set<CPPType *>::iterator ii = _external_imports.begin(); ii != _external_imports.end(); ii++) {
CPPType *type = (*ii);
@ -897,9 +893,9 @@ write_prototypes_class_external(ostream &out, Object *obj) {
std::string preferred_name = obj->_itype.get_name();
out << "//********************************************************************\n";
out << "//*** prototypes for external.. " << class_name << "\n";
out << "//********************************************************************\n";
out << "/**\n";
out << " * Forward declaration of class " << class_name << "\n";
out << " */\n";
// This typedef is necessary for class templates since we can't pass a comma
// to a macro function.
@ -915,9 +911,9 @@ write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) {
std::string ClassName = make_safe_name(obj->_itype.get_scoped_name());
Functions::iterator fi;
out_code << "//********************************************************************\n";
out_code << "//*** prototypes for .. " << ClassName << "\n";
out_code << "//********************************************************************\n";
out_code << "/**\n";
out_code << " * Forward declarations for top-level class " << ClassName << "\n";
out_code << " */\n";
/*
for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) {
@ -943,9 +939,9 @@ write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) {
*/
void InterfaceMakerPythonNative::
write_functions(ostream &out) {
out << "//********************************************************************\n";
out << "//*** Functions for .. Global\n" ;
out << "//********************************************************************\n";
out << "/**\n";
out << " * Python wrappers for global functions\n" ;
out << " */\n";
FunctionsByIndex::iterator fi;
for (fi = _functions.begin(); fi != _functions.end(); ++fi) {
Function *func = (*fi).second;
@ -994,9 +990,9 @@ write_class_details(ostream &out, Object *obj) {
std::string ClassName = make_safe_name(obj->_itype.get_scoped_name());
std::string cClassName = obj->_itype.get_true_name();
out << "//********************************************************************\n";
out << "//*** Functions for .. " << cClassName << "\n" ;
out << "//********************************************************************\n";
out << "/**\n";
out << " * Python wrappers for functions of class " << cClassName << "\n" ;
out << " */\n";
// First write out all the wrapper functions for the methods.
for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) {
@ -1017,13 +1013,21 @@ write_class_details(ostream &out, Object *obj) {
}
// Write the constructors.
std::string fname = "static int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)";
for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) {
Function *func = (*fi);
std::string fname = "static int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)";
string expected_params;
write_function_for_name(out, obj, func->_remaps, fname, expected_params, true, AT_keyword_args, RF_int);
}
if (obj->_constructors.size() == 0) {
// We still need to write a dummy constructor to prevent inheriting the
// constructor from a base class.
out << fname << " {\n"
" Dtool_Raise_TypeError(\"cannot init abstract class\");\n"
" return -1;\n"
"}\n\n";
}
CPPType *cpptype = TypeManager::resolve_type(obj->_itype._cpptype);
@ -1183,7 +1187,6 @@ write_sub_module(ostream &out, Object *obj) {
// Object * obj = _objects[_embeded_index] ;
string class_name = make_safe_name(obj->_itype.get_scoped_name());
string class_ptr;
out << " // Module init upcall for " << obj->_itype.get_scoped_name() << "\n";
if (!obj->_itype.is_typedef()) {
out << " // " << *(obj->_itype._cpptype) << "\n";
@ -1242,9 +1245,9 @@ write_sub_module(ostream &out, Object *obj) {
*/
void InterfaceMakerPythonNative::
write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
out << "//********************************************************************\n";
out << "//*** Module Object Linker ..\n";
out << "//********************************************************************\n";
out << "/**\n";
out << " * Module Object Linker ..\n";
out << " */\n";
Objects::iterator oi;
@ -1305,14 +1308,41 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
if (object->_itype.is_enum() && !object->_itype.is_nested() &&
isExportThisRun(object->_itype._cpptype)) {
int enum_count = object->_itype.number_of_enum_values();
for (int xx = 0; xx < enum_count; xx++) {
string name1 = classNameFromCppName(object->_itype.get_enum_value_name(xx), false);
string name2 = classNameFromCppName(object->_itype.get_enum_value_name(xx), true);
string enum_value = "::" + object->_itype.get_enum_value_name(xx);
out << " PyModule_AddIntConstant(module, \"" << name1 << "\", " << enum_value << ");\n";
if (name1 != name2) {
// Also write the mangled name, for historical purposes.
out << " PyModule_AddIntConstant(module, \"" << name2 << "\", " << enum_value << ");\n";
if (object->_itype.is_scoped_enum()) {
// Convert as Python 3.4 enum.
CPPType *underlying_type = TypeManager::unwrap_const(object->_itype._cpptype->as_enum_type()->get_underlying_type());
string cast_to = underlying_type->get_local_name(&parser);
out << "#if PY_VERSION_HEX >= 0x03040000\n\n";
out << " // enum class " << object->_itype.get_scoped_name() << "\n";
out << " {\n";
out << " PyObject *members = PyTuple_New(" << enum_count << ");\n";
out << " PyObject *member;\n";
for (int xx = 0; xx < enum_count; xx++) {
out << " member = PyTuple_New(2);\n"
" PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\""
<< object->_itype.get_enum_value_name(xx) << "\"));\n"
" PyTuple_SET_ITEM(member, 1, Dtool_WrapValue(("
<< cast_to << ")" << object->_itype.get_scoped_name() << "::"
<< object->_itype.get_enum_value_name(xx) << "));\n"
" PyTuple_SET_ITEM(members, " << xx << ", member);\n";
}
out << " PyModule_AddObject(module, \"" << object->_itype.get_name()
<< "\", Dtool_EnumType_Create(\"" << object->_itype.get_name()
<< "\", members, \"" << _def->module_name << "\"));\n";
out << " }\n";
out << "#endif\n";
} else {
out << " // enum " << object->_itype.get_scoped_name() << "\n";
for (int xx = 0; xx < enum_count; xx++) {
string name1 = classNameFromCppName(object->_itype.get_enum_value_name(xx), false);
string name2 = classNameFromCppName(object->_itype.get_enum_value_name(xx), true);
string enum_value = "::" + object->_itype.get_enum_value_name(xx);
out << " PyModule_AddObject(module, \"" << name1 << "\", Dtool_WrapValue(" << enum_value << "));\n";
if (name1 != name2) {
// Also write the mangled name, for historical purposes.
out << " PyModule_AddObject(module, \"" << name2 << "\", Dtool_WrapValue(" << enum_value << "));\n";
}
}
}
}
@ -1360,13 +1390,6 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
}
}
}
out << "//********************************************************************\n";
out << "//*** Module Init Upcall .. Externally Defined Class\n";
out << "//********************************************************************\n";
// for (std::set< std::string >::iterator ii = _external_imports.begin(); ii
// != _external_imports.end(); ii++) out << "Dtool_" <<*ii <<
// "._Dtool_ClassInit(NULL);\n";
out << "}\n\n";
@ -1435,9 +1458,9 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
InterfaceMakerPython::write_module(out, out_h, def);
Objects::iterator oi;
out << "//********************************************************************\n";
out << "//*** Py Init Code For .. GlobalScope\n" ;
out << "//********************************************************************\n";
out << "/**\n";
out << " * Module initialization functions for Python module \"" << def->module_name << "\"\n";
out << " */\n";
out << "#if PY_MAJOR_VERSION >= 3\n"
<< "static struct PyModuleDef python_native_module = {\n"
@ -1452,14 +1475,16 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
<< "#ifdef _WIN32\n"
<< "extern \"C\" __declspec(dllexport) PyObject *PyInit_" << def->module_name << "();\n"
<< "#elif __GNUC__ >= 4\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) PyInit_" << def->module_name << "();\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) PyObject *PyInit_" << def->module_name << "();\n"
<< "#else\n"
<< "extern \"C\" PyObject *PyInit_" << def->module_name << "();\n"
<< "#endif\n"
<< "\n"
<< "PyObject *PyInit_" << def->module_name << "() {\n"
<< " LibraryDef *refs[] = {&" << def->library_name << "_moddef, NULL};\n"
<< " return Dtool_PyModuleInitHelper(refs, &python_native_module);\n"
<< " PyObject *module = Dtool_PyModuleInitHelper(refs, &python_native_module);\n"
<< " Dtool_" << def->library_name << "_BuildInstants(module);\n"
<< " return module;\n"
<< "}\n"
<< "\n"
<< "#else // Python 2 case\n"
@ -1467,14 +1492,15 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) {
<< "#ifdef _WIN32\n"
<< "extern \"C\" __declspec(dllexport) void init" << def->module_name << "();\n"
<< "#elif __GNUC__ >= 4\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) init" << def->module_name << "();\n"
<< "extern \"C\" __attribute__((visibility(\"default\"))) void init" << def->module_name << "();\n"
<< "#else\n"
<< "extern \"C\" void init" << def->module_name << "();\n"
<< "#endif\n"
<< "\n"
<< "void init" << def->module_name << "() {\n"
<< " LibraryDef *refs[] = {&" << def->library_name << "_moddef, NULL};\n"
<< " Dtool_PyModuleInitHelper(refs, \"" << def->module_name << "\");\n"
<< " PyObject *module = Dtool_PyModuleInitHelper(refs, \"" << def->module_name << "\");\n"
<< " Dtool_" << def->library_name << "_BuildInstants(module);\n"
<< "}\n"
<< "\n"
<< "#endif\n"
@ -1520,9 +1546,9 @@ write_module_class(ostream &out, Object *obj) {
}
Functions::iterator fi;
out << "//********************************************************************\n";
out << "//*** Py Init Code For .. " << ClassName << " | " << export_class_name << "\n" ;
out << "//********************************************************************\n";
out << "/**\n";
out << " * Python method tables for " << ClassName << " (" << export_class_name << ")\n" ;
out << " */\n";
out << "static PyMethodDef Dtool_Methods_" << ClassName << "[] = {\n";
SlottedFunctions slots;
@ -2449,11 +2475,7 @@ write_module_class(ostream &out, Object *obj) {
<< classNameFromCppName(ClassName, false) << "\");\n";
}
out << " std::string ss = os.str();\n";
out << "#if PY_MAJOR_VERSION >= 3\n";
out << " return PyUnicode_FromStringAndSize(ss.data(), ss.length());\n";
out << "#else\n";
out << " return PyString_FromStringAndSize(ss.data(), ss.length());\n";
out << "#endif\n";
out << " return Dtool_WrapValue(ss);\n";
out << "}\n\n";
has_local_repr = true;
}
@ -2479,11 +2501,7 @@ write_module_class(ostream &out, Object *obj) {
out << " local_this->write(os);\n";
}
out << " std::string ss = os.str();\n";
out << "#if PY_MAJOR_VERSION >= 3\n";
out << " return PyUnicode_FromStringAndSize(ss.data(), ss.length());\n";
out << "#else\n";
out << " return PyString_FromStringAndSize(ss.data(), ss.length());\n";
out << "#endif\n";
out << " return Dtool_WrapValue(ss);\n";
out << "}\n\n";
has_local_str = true;
}
@ -2608,7 +2626,8 @@ write_module_class(ostream &out, Object *obj) {
string getter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter";
string setter = "NULL";
if (property->_setter != NULL && is_function_legal(property->_setter)) {
if (property->_length_function == NULL &&
property->_setter != NULL && is_function_legal(property->_setter)) {
setter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter";
}
@ -2921,11 +2940,7 @@ write_module_class(ostream &out, Object *obj) {
// Py_ssize_t tp_dictoffset;
out << " 0, // tp_dictoffset\n";
// initproc tp_init;
if (obj->_constructors.size() > 0) {
out << " Dtool_Init_" << ClassName << ",\n";
} else {
out << " 0,\n";
}
out << " Dtool_Init_" << ClassName << ",\n";
// allocfunc tp_alloc;
out << " PyType_GenericAlloc,\n";
// newfunc tp_new;
@ -3037,7 +3052,7 @@ write_module_class(ostream &out, Object *obj) {
} else if (nested_obj->_itype.is_typedef()) {
++num_dict_items;
} else if (nested_obj->_itype.is_enum()) {
} else if (nested_obj->_itype.is_enum() && !nested_obj->_itype.is_scoped_enum()) {
CPPEnumType *enum_type = nested_obj->_itype._cpptype->as_enum_type();
num_dict_items += 2 * enum_type->_elements.size();
}
@ -3095,8 +3110,33 @@ write_module_class(ostream &out, Object *obj) {
// No need to support mangled names for nested typedefs; we only added
// support recently.
} else if (nested_obj->_itype.is_scoped_enum()) {
// Convert enum class as Python 3.4 enum.
int enum_count = nested_obj->_itype.number_of_enum_values();
CPPType *underlying_type = TypeManager::unwrap_const(nested_obj->_itype._cpptype->as_enum_type()->get_underlying_type());
string cast_to = underlying_type->get_local_name(&parser);
out << "#if PY_VERSION_HEX >= 0x03040000\n\n";
out << " // enum class " << nested_obj->_itype.get_scoped_name() << ";\n";
out << " {\n";
out << " PyObject *members = PyTuple_New(" << enum_count << ");\n";
out << " PyObject *member;\n";
for (int xx = 0; xx < enum_count; xx++) {
out << " member = PyTuple_New(2);\n"
" PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\""
<< nested_obj->_itype.get_enum_value_name(xx) << "\"));\n"
" PyTuple_SET_ITEM(member, 1, Dtool_WrapValue(("
<< cast_to << ")" << nested_obj->_itype.get_scoped_name() << "::"
<< nested_obj->_itype.get_enum_value_name(xx) << "));\n"
" PyTuple_SET_ITEM(members, " << xx << ", member);\n";
}
out << " PyDict_SetItemString(dict, \"" << nested_obj->_itype.get_name()
<< "\", Dtool_EnumType_Create(\"" << nested_obj->_itype.get_name()
<< "\", members, \"" << _def->module_name << "\"));\n";
out << " }\n";
out << "#endif\n";
} else if (nested_obj->_itype.is_enum()) {
out << " // Enum " << nested_obj->_itype.get_scoped_name() << ";\n";
out << " // enum " << nested_obj->_itype.get_scoped_name() << ";\n";
CPPEnumType *enum_type = nested_obj->_itype._cpptype->as_enum_type();
CPPEnumType::Elements::const_iterator ei;
for (ei = enum_type->_elements.begin(); ei != enum_type->_elements.end(); ++ei) {
@ -3111,9 +3151,9 @@ write_module_class(ostream &out, Object *obj) {
name2 = name1;
}
string enum_value = obj->_itype.get_scoped_name() + "::" + (*ei)->get_simple_name();
out << " PyDict_SetItemString(dict, \"" << name1 << "\", PyLongOrInt_FromLong(" << enum_value << "));\n";
out << " PyDict_SetItemString(dict, \"" << name1 << "\", Dtool_WrapValue(" << enum_value << "));\n";
if (name1 != name2) {
out << " PyDict_SetItemString(dict, \"" << name2 << "\", PyLongOrInt_FromLong(" << enum_value << "));\n";
out << " PyDict_SetItemString(dict, \"" << name2 << "\", Dtool_WrapValue(" << enum_value << "));\n";
}
}
}
@ -3340,7 +3380,7 @@ write_function_for_name(ostream &out, Object *obj,
int max_required_args = 0;
bool all_nonconst = true;
out << "/******************************************************************\n" << " * Python type method wrapper for\n";
out << "/**\n * Python function wrapper for:\n";
for (ri = remaps.begin(); ri != remaps.end(); ++ri) {
remap = (*ri);
if (is_remap_legal(remap)) {
@ -3369,7 +3409,7 @@ write_function_for_name(ostream &out, Object *obj,
}
}
out << " *******************************************************************/\n";
out << " */\n";
out << function_name << " {\n";
@ -3935,13 +3975,7 @@ collapse_default_remaps(std::map<int, std::set<FunctionRemap *> > &map_sets,
goto abort_iteration;
}
}
} else if (TypeManager::is_bool(type)) {
} else if (TypeManager::is_char(type)) {
} else if (TypeManager::is_wchar(type)) {
goto abort_iteration;
} else if (TypeManager::is_longlong(type)) {
} else if (TypeManager::is_integer(type)) {
} else if (TypeManager::is_double(type)) {
} else if (TypeManager::is_float(type)) {
} else if (TypeManager::is_const_char_pointer(type)) {
} else if (TypeManager::is_pointer_to_PyTypeObject(type)) {
@ -6033,164 +6067,16 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap,
CPPType *orig_type = return_type->get_orig_type();
CPPType *type = return_type->get_new_type();
if (return_type->new_type_is_atomic_string()) {
if (TypeManager::is_char_pointer(orig_type)) {
indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n";
indent(out, indent_level) << " Py_INCREF(Py_None);\n";
indent(out, indent_level) << " return Py_None;\n";
indent(out, indent_level) << "} else {\n";
out << "#if PY_MAJOR_VERSION >= 3\n";
indent(out, indent_level) << " return "
<< "PyUnicode_FromString(" << return_expr << ");\n";
out << "#else\n";
indent(out, indent_level) << " return "
<< "PyString_FromString(" << return_expr << ");\n";
out << "#endif\n";
indent(out, indent_level) << "}\n";
} else if (TypeManager::is_wchar_pointer(orig_type)) {
indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n";
indent(out, indent_level) << " Py_INCREF(Py_None);\n";
indent(out, indent_level) << " return Py_None;\n";
indent(out, indent_level) << "} else {\n";
indent(out, indent_level+2)
<< "return PyUnicode_FromWideChar("
<< return_expr << ", wcslen(" << return_expr << "));\n";
indent(out, indent_level) << "}\n";
} else if (TypeManager::is_wstring(orig_type)) {
indent(out, indent_level)
<< "return PyUnicode_FromWideChar("
<< return_expr << ".data(), (int) " << return_expr << ".length());\n";
} else if (TypeManager::is_const_ptr_to_basic_string_wchar(orig_type)) {
indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n";
indent(out, indent_level) << " Py_INCREF(Py_None);\n";
indent(out, indent_level) << " return Py_None;\n";
indent(out, indent_level) << "} else {\n";
indent(out, indent_level) << " return "
<< "PyUnicode_FromWideChar("
<< return_expr << "->data(), (int) " << return_expr << "->length());\n";
indent(out, indent_level) << "}\n";
} else if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) {
indent(out, indent_level) << "if (" << return_expr<< " == NULL) {\n";
indent(out, indent_level) << " Py_INCREF(Py_None);\n";
indent(out, indent_level) << " return Py_None;\n";
indent(out, indent_level) << "} else {\n";
out << "#if PY_MAJOR_VERSION >= 3\n";
indent(out, indent_level) << " return "
<< "PyUnicode_FromStringAndSize("
<< return_expr << "->data(), (Py_ssize_t)" << return_expr << "->length());\n";
out << "#else\n";
indent(out, indent_level) << " return "
<< "PyString_FromStringAndSize("
<< return_expr << "->data(), (Py_ssize_t)" << return_expr << "->length());\n";
out << "#endif\n";
indent(out, indent_level) << "}\n";
} else {
out << "#if PY_MAJOR_VERSION >= 3\n";
indent(out, indent_level)
<< "return PyUnicode_FromStringAndSize("
<< return_expr << ".data(), (Py_ssize_t)" << return_expr << ".length());\n";
out << "#else\n";
indent(out, indent_level)
<< "return PyString_FromStringAndSize("
<< return_expr << ".data(), (Py_ssize_t)" << return_expr << ".length());\n";
out << "#endif\n";
}
} else if (TypeManager::is_bool(type)) {
if (return_type->new_type_is_atomic_string() ||
TypeManager::is_simple(type) ||
TypeManager::is_char_pointer(type) ||
TypeManager::is_wchar_pointer(type) ||
TypeManager::is_pointer_to_PyObject(type) ||
TypeManager::is_pointer_to_Py_buffer(type)) {
// Most types are now handled by the many overloads of Dtool_WrapValue,
// defined in py_panda.h.
indent(out, indent_level)
<< "return PyBool_FromLong(" << return_expr << ");\n";
} else if (TypeManager::is_ssize(type)) {
indent(out, indent_level)
<< "return PyLongOrInt_FromSsize_t(" << return_expr << ");\n";
} else if (TypeManager::is_size(type)) {
indent(out, indent_level)
<< "return PyLongOrInt_FromSize_t(" << return_expr << ");\n";
} else if (TypeManager::is_char(type)) {
out << "#if PY_MAJOR_VERSION >= 3\n";
indent(out, indent_level)
<< "return PyUnicode_FromStringAndSize(&" << return_expr << ", 1);\n";
out << "#else\n";
indent(out, indent_level)
<< "return PyString_FromStringAndSize(&" << return_expr << ", 1);\n";
out << "#endif\n";
} else if (TypeManager::is_wchar(type)) {
indent(out, indent_level)
<< "return PyUnicode_FromWideChar(&" << return_expr << ", 1);\n";
} else if (TypeManager::is_unsigned_longlong(type)) {
indent(out, indent_level)
<< "return PyLong_FromUnsignedLongLong(" << return_expr << ");\n";
} else if (TypeManager::is_longlong(type)) {
indent(out, indent_level)
<< "return PyLong_FromLongLong(" << return_expr << ");\n";
} else if (TypeManager::is_unsigned_integer(type)){
indent(out, indent_level)
<< "return PyLongOrInt_FromUnsignedLong(" << return_expr << ");\n";
} else if (TypeManager::is_integer(type)) {
indent(out, indent_level)
<< "return PyLongOrInt_FromLong(" << return_expr << ");\n";
} else if (TypeManager::is_float(type)) {
indent(out, indent_level)
<< "return PyFloat_FromDouble(" << return_expr << ");\n";
} else if (TypeManager::is_char_pointer(type)) {
indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n";
indent(out, indent_level) << " Py_INCREF(Py_None);\n";
indent(out, indent_level) << " return Py_None;\n";
indent(out, indent_level) << "} else {\n";
out << "#if PY_MAJOR_VERSION >= 3\n";
indent(out, indent_level) << " return "
<< "PyUnicode_FromString(" << return_expr << ");\n";
out << "#else\n";
indent(out, indent_level) << " return "
<< "PyString_FromString(" << return_expr << ");\n";
out << "#endif\n";
indent(out, indent_level) << "}\n";
} else if (TypeManager::is_wchar_pointer(type)) {
indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n";
indent(out, indent_level) << " Py_INCREF(Py_None);\n";
indent(out, indent_level) << " return Py_None;\n";
indent(out, indent_level) << "} else {\n";
indent(out, indent_level) << " return "
<< "PyUnicode_FromWideChar("
<< return_expr << ", wcslen(" << return_expr << "));\n";
indent(out, indent_level) << "}\n";
} else if (TypeManager::is_pointer_to_PyObject(type)) {
indent(out, indent_level)
<< "return " << return_expr << ";\n";
} else if (TypeManager::is_pointer_to_Py_buffer(type)) {
indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n";
indent(out, indent_level) << " Py_INCREF(Py_None);\n";
indent(out, indent_level) << " return Py_None;\n";
indent(out, indent_level) << "} else {\n";
indent(out, indent_level) << " return "
<< "PyMemoryView_FromBuffer(" << return_expr << ");\n";
indent(out, indent_level) << "}\n";
<< "return Dtool_WrapValue(" << return_expr << ");\n";
} else if (TypeManager::is_pointer(type)) {
bool is_const = TypeManager::is_const_pointer_to_anything(type);
@ -6234,13 +6120,13 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap,
} else {
indent(out, indent_level) << "Should Never Reach This InterfaceMakerPythonNative::pack_python_value";
// << "return PyLongOrInt_FromLong((int) " << return_expr << ");\n";
// << "return Dtool_Integer((int) " << return_expr << ");\n";
}
} else {
// Return None.
indent(out, indent_level)
<< "return Py_BuildValue(\"\");\n";
<< "return Py_BuildValue(\"\"); // Don't know how to wrap type.\n";
}
}
@ -6251,8 +6137,9 @@ void InterfaceMakerPythonNative::
write_make_seq(ostream &out, Object *obj, const std::string &ClassName,
const std::string &cClassName, MakeSeq *make_seq) {
out << "/******************************************************************\n" << " * Python make_seq wrapper\n";
out << " *******************************************************************/\n";
out << "/*\n"
" * Python make_seq wrapper\n"
" */\n";
out << "static PyObject *" << make_seq->_name + "(PyObject *self, PyObject *) {\n";
@ -6288,11 +6175,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName,
" PyObject *tuple = PyTuple_New(count);\n"
"\n"
" for (Py_ssize_t i = 0; i < count; ++i) {\n"
"#if PY_MAJOR_VERSION >= 3\n"
" PyObject *index = PyLong_FromSsize_t(i);\n"
"#else\n"
" PyObject *index = PyInt_FromSsize_t(i);\n"
"#endif\n";
" PyObject *index = Dtool_WrapValue(i);\n";
switch (elem_getter->_args_type) {
case AT_keyword_args:
@ -6345,10 +6228,156 @@ write_getset(ostream &out, Object *obj, Property *property) {
const InterrogateElement &ielem = property->_ielement;
if (property->_getter != NULL) {
if (property->_length_function != NULL) {
// This is actually a sequence. Wrap this with a special class.
FunctionRemap *len_remap = property->_length_function->_remaps.front();
vector_string pexprs;
out << "/**\n"
" * sequence length function for property " << cClassName << "::" << ielem.get_name() << "\n"
" */\n"
"static Py_ssize_t Dtool_" + ClassName + "_" + ielem.get_name() + "_Len(PyObject *self) {\n";
if (property->_length_function->_has_this) {
out <<
" " << cClassName << " *local_this = NULL;\n"
" if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"
" return NULL;\n"
" }\n"
" return (Py_ssize_t)" << len_remap->get_call_str("local_this", pexprs) << ";\n";
} else {
out << " return (Py_ssize_t)" << len_remap->get_call_str("", pexprs) << ";\n";
}
out << "}\n\n";
// Now write out the getitem helper function.
if (property->_getter != NULL) {
out <<
"/**\n"
" * sequence getter for property " << cClassName << "::" << ielem.get_name() << "\n"
" */\n"
"static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getitem(PyObject *self, Py_ssize_t index) {\n"
" " << cClassName << " *local_this = NULL;\n"
" if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"
" return NULL;\n"
" }\n";
// This is a getitem of a sequence type. This means we *need* to raise
// IndexError if we're out of bounds.
out << " if (index < 0 || index >= (Py_ssize_t)"
<< len_remap->get_call_str("local_this", pexprs) << ") {\n";
out << " PyErr_SetString(PyExc_IndexError, \"" << ClassName << "." << ielem.get_name() << "[] index out of range\");\n";
out << " return NULL;\n";
out << " }\n";
if (property->_has_function != NULL) {
out << " if (!local_this->" << property->_has_function->_ifunc.get_name() << "(index)) {\n"
<< " Py_INCREF(Py_None);\n"
<< " return Py_None;\n"
<< " }\n";
}
std::set<FunctionRemap*> remaps;
// Extract only the getters that take one argument.
Function::Remaps::iterator it;
for (it = property->_getter->_remaps.begin();
it != property->_getter->_remaps.end();
++it) {
FunctionRemap *remap = *it;
int min_num_args = remap->get_min_num_args();
int max_num_args = remap->get_max_num_args();
if (min_num_args <= 1 && max_num_args >= 1) {
remaps.insert(remap);
}
}
string expected_params;
write_function_forset(out, remaps, 1, 1, expected_params, 2, true, true,
AT_no_args, RF_pyobject | RF_err_null, false, true, "index");
out << " if (!_PyErr_OCCURRED()) {\n";
out << " return Dtool_Raise_BadArgumentsError(\n";
output_quoted(out, 6, expected_params);
out << ");\n"
" }\n"
"}\n\n";
}
// Write out a setitem if this is not a read-only property.
if (property->_setter != NULL) {
out << "static int Dtool_" + ClassName + "_" + ielem.get_name() + "_Setitem(PyObject *self, Py_ssize_t index, PyObject *arg) {\n";
out << " " << cClassName << " *local_this = NULL;\n";
out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \""
<< classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n";
out << " return -1;\n";
out << " }\n\n";
out << " if (arg == (PyObject *)NULL) {\n";
if (property->_deleter != NULL) {
out << " local_this->" << property->_deleter->_ifunc.get_name() << "(index);\n"
<< " return 0;\n";
} else {
out << " Dtool_Raise_TypeError(\"can't delete " << ielem.get_name() << "[] attribute\");\n"
" return -1;\n";
}
out << " }\n";
if (property->_clear_function != NULL) {
out << " if (arg == Py_None) {\n"
<< " local_this->" << property->_clear_function->_ifunc.get_name() << "(index);\n"
<< " return 0;\n"
<< " }\n";
}
std::set<FunctionRemap*> remaps;
// Extract only the setters that take two arguments.
Function::Remaps::iterator it;
for (it = property->_setter->_remaps.begin();
it != property->_setter->_remaps.end();
++it) {
FunctionRemap *remap = *it;
int min_num_args = remap->get_min_num_args();
int max_num_args = remap->get_max_num_args();
if (min_num_args <= 2 && max_num_args >= 2) {
remaps.insert(remap);
}
}
string expected_params;
write_function_forset(out, remaps, 2, 2,
expected_params, 2, true, true, AT_single_arg,
RF_int, false, false, "index");
out << " if (!_PyErr_OCCURRED()) {\n";
out << " Dtool_Raise_BadArgumentsError(\n";
output_quoted(out, 6, expected_params);
out << ");\n";
out << " }\n";
out << " return -1;\n";
out << "}\n\n";
}
// Now write the getter, which returns a special wrapper object.
out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"
" Py_INCREF(self);\n"
" Dtool_SequenceWrapper *wrap = PyObject_New(Dtool_SequenceWrapper, &Dtool_SequenceWrapper_Type);\n"
" wrap->_base = self;\n"
" wrap->_len_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Len;\n"
" wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Getitem;\n";
if (property->_setter != NULL) {
out << " wrap->_setitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Setitem;\n";
} else {
out << " wrap->_setitem_func = NULL;\n";
}
out << " return (PyObject *)wrap;\n"
"}\n\n";
} else if (property->_getter != NULL) {
// Write out a regular, unwrapped getter.
out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n";
FunctionRemap *remap = property->_getter->_remaps.front();
out << "PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n";
if (remap->_const_method) {
out << " const " << cClassName << " *local_this = NULL;\n";
out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n";
@ -6375,50 +6404,61 @@ write_getset(ostream &out, Object *obj, Property *property) {
expected_params, 2, false, true, AT_no_args,
RF_pyobject | RF_err_null, false, false);
out << "}\n\n";
}
if (property->_setter != NULL) {
out << "int Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter(PyObject *self, PyObject *arg, void *) {\n";
out << " " << cClassName << " *local_this = NULL;\n";
out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \""
<< classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n";
out << " return -1;\n";
out << " }\n\n";
// Write out a setter if this is not a read-only property.
if (property->_setter != NULL) {
out << "static int Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter(PyObject *self, PyObject *arg, void *) {\n";
out << " " << cClassName << " *local_this = NULL;\n";
out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \""
<< classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n";
out << " return -1;\n";
out << " }\n\n";
if (property->_clear_function != NULL) {
out << " if (arg == Py_None) {\n"
<< " local_this->" << property->_clear_function->_ifunc.get_name() << "();\n"
<< " return 0;\n"
<< " }\n";
}
std::set<FunctionRemap*> remaps;
// Extract only the setters that take one argument.
Function::Remaps::iterator it;
for (it = property->_setter->_remaps.begin();
it != property->_setter->_remaps.end();
++it) {
FunctionRemap *remap = *it;
int min_num_args = remap->get_min_num_args();
int max_num_args = remap->get_max_num_args();
if (min_num_args <= 1 && max_num_args >= 1) {
remaps.insert(remap);
out << " if (arg == (PyObject *)NULL) {\n";
if (property->_deleter != NULL) {
out << " local_this->" << property->_deleter->_ifunc.get_name() << "();\n"
<< " return 0;\n";
} else {
out << " Dtool_Raise_TypeError(\"can't delete " << ielem.get_name() << " attribute\");\n"
" return -1;\n";
}
out << " }\n";
if (property->_clear_function != NULL) {
out << " if (arg == Py_None) {\n"
<< " local_this->" << property->_clear_function->_ifunc.get_name() << "();\n"
<< " return 0;\n"
<< " }\n";
}
std::set<FunctionRemap*> remaps;
// Extract only the setters that take one argument.
Function::Remaps::iterator it;
for (it = property->_setter->_remaps.begin();
it != property->_setter->_remaps.end();
++it) {
FunctionRemap *remap = *it;
int min_num_args = remap->get_min_num_args();
int max_num_args = remap->get_max_num_args();
if (min_num_args <= 1 && max_num_args >= 1) {
remaps.insert(remap);
}
}
string expected_params;
write_function_forset(out, remaps, 1, 1,
expected_params, 2, true, true, AT_single_arg,
RF_int, false, false);
out << " if (!_PyErr_OCCURRED()) {\n";
out << " Dtool_Raise_BadArgumentsError(\n";
output_quoted(out, 6, expected_params);
out << ");\n";
out << " }\n";
out << " return -1;\n";
out << "}\n\n";
}
string expected_params;
write_function_forset(out, remaps, 1, 1,
expected_params, 2, true, true, AT_single_arg,
RF_int, false, false);
out << " if (!_PyErr_OCCURRED()) {\n";
out << " Dtool_Raise_BadArgumentsError(\n";
output_quoted(out, 6, expected_params);
out << ");\n";
out << " }\n";
out << " return -1;\n";
out << "}\n\n";
}
}
@ -6543,6 +6583,19 @@ record_object(TypeIndex type_index) {
}
}
if (ielement.has_del_function()) {
FunctionIndex func_index = ielement.get_del_function();
Function *del_function = record_function(itype, func_index);
if (is_function_legal(del_function)) {
property->_deleter = del_function;
}
}
if (ielement.is_sequence()) {
FunctionIndex func_index = ielement.get_length_function();
property->_length_function = record_function(itype, func_index);
}
if (property->_getter != NULL) {
object->_properties.push_back(property);
} else {

View File

@ -1782,9 +1782,9 @@ get_function(CPPInstance *function, string description,
}
/**
* Adds the indicated make_property to the database, if it is not already
* present. In either case, returns the MakeSeqIndex of the make_seq within
* the database.
* Adds the indicated make_property or make_seq_property to the database, if
* it is not already present. In either case, returns the ElementIndex
* of the created property within the database.
*/
ElementIndex InterrogateBuilder::
get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CPPScope *scope) {
@ -1805,20 +1805,58 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
return index;
}
// If we have a length function (ie. this is a sequence property), we should
// find the function that will give us the length.
FunctionIndex length_function = 0;
bool is_seq = false;
CPPFunctionGroup::Instances::const_iterator fi;
CPPFunctionGroup *fgroup = make_property->_length_function;
if (fgroup != NULL) {
is_seq = true;
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
CPPInstance *function = (*fi);
CPPFunctionType *ftype =
function->_type->as_function_type();
if (ftype != NULL) {
length_function = get_function(function, "", struct_type,
struct_type->get_scope(), 0);
if (length_function != 0) {
break;
}
}
}
if (length_function == 0) {
cerr << "No instance of length method '"
<< fgroup->_name << "' is suitable!\n";
return 0;
}
}
// Find the getter so we can get its return type.
CPPInstance *getter = NULL;
CPPType *return_type = NULL;
CPPFunctionGroup *fgroup = make_property->_get_function;
fgroup = make_property->_get_function;
if (fgroup != NULL) {
CPPFunctionGroup::Instances::const_iterator fi;
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
CPPInstance *function = (*fi);
CPPFunctionType *ftype = function->_type->as_function_type();
if (ftype == NULL) {
continue;
}
// The getter must either take no arguments, or all defaults.
if (ftype != NULL && (ftype->_parameters->_parameters.size() == 0 ||
ftype->_parameters->_parameters[0]->_initializer != NULL)) {
if (ftype->_parameters->_parameters.size() == (int)is_seq ||
(ftype->_parameters->_parameters.size() > (int)is_seq &&
ftype->_parameters->_parameters[(int)is_seq]->_initializer != NULL)) {
// If this is a sequence getter, it must take an index argument.
if (is_seq && !TypeManager::is_integer(ftype->_parameters->_parameters[0]->_type)) {
continue;
}
getter = function;
return_type = ftype->_return_type;
@ -1860,6 +1898,28 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
}
}
// And the "deleter".
CPPInstance *deleter = NULL;
fgroup = make_property->_del_function;
if (fgroup != NULL) {
CPPFunctionGroup::Instances::const_iterator fi;
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
CPPInstance *function = (*fi);
CPPFunctionType *ftype = function->_type->as_function_type();
if (ftype != NULL && ftype->_parameters->_parameters.size() == (int)is_seq) {
deleter = function;
break;
}
}
if (deleter == NULL || return_type == NULL) {
cerr << "No instance of delete-function '"
<< fgroup->_name << "' is suitable!\n";
return 0;
}
}
InterrogateDatabase *idb = InterrogateDatabase::get_ptr();
// It isn't here, so we'll have to define it.
ElementIndex index = idb->get_next_index();
@ -1875,22 +1935,30 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
iproperty._type = 0;
}
if (length_function != 0) {
iproperty._flags |= InterrogateElement::F_sequence;
iproperty._length_function = length_function;
}
if (getter != NULL) {
iproperty._flags |= InterrogateElement::F_has_getter;
iproperty._getter = get_function(getter, "", struct_type,
struct_type->get_scope(), 0);
if (iproperty._getter == 0) {
cerr << "failed " << *getter << "\n";
}
nassertr(iproperty._getter, 0);
}
if (hasser != NULL) {
iproperty._flags |= InterrogateElement::F_has_has_function;
iproperty._has_function = get_function(hasser, "", struct_type,
struct_type->get_scope(), 0);
if (iproperty._has_function == 0) {
cerr << "failed " << *hasser << "\n";
}
nassertr(iproperty._has_function, 0);
}
if (deleter != NULL) {
iproperty._flags |= InterrogateElement::F_has_del_function;
iproperty._del_function = get_function(deleter, "", struct_type,
struct_type->get_scope(), 0);
nassertr(iproperty._del_function, 0);
}
// See if there happens to be a comment before the MAKE_PROPERTY macro.
@ -1907,9 +1975,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
iproperty._flags |= InterrogateElement::F_has_setter;
iproperty._setter = get_function(function, "", struct_type,
struct_type->get_scope(), 0);
if (iproperty._setter == 0) {
cerr << "failed " << *function << "\n";
}
nassertr(iproperty._setter, 0);
break;
}
}
@ -1922,15 +1988,12 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
iproperty._flags |= InterrogateElement::F_has_clear_function;
iproperty._clear_function = get_function(function, "", struct_type,
struct_type->get_scope(), 0);
if (iproperty._clear_function == 0) {
cerr << "failed " << *function << "\n";
}
nassertr(iproperty._clear_function, 0);
break;
}
}
idb->add_element(index, iproperty);
return index;
}
@ -2838,6 +2901,10 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) {
return;
}
if (cpptype->is_scoped()) {
itype._flags |= InterrogateType::F_scoped_enum;
}
int next_value = 0;
CPPEnumType::Elements::const_iterator ei;
@ -2919,6 +2986,8 @@ define_extension_type(InterrogateType &itype, CPPExtensionType *cpptype) {
// But we can at least indicate which of the various extension types it is.
switch (cpptype->_type) {
case CPPExtensionType::T_enum:
case CPPExtensionType::T_enum_class:
case CPPExtensionType::T_enum_struct:
itype._flags |= InterrogateType::F_enum;
break;

View File

@ -20,7 +20,7 @@ InterrogateDatabase *InterrogateDatabase::_global_ptr = NULL;
int InterrogateDatabase::_file_major_version = 0;
int InterrogateDatabase::_file_minor_version = 0;
int InterrogateDatabase::_current_major_version = 3;
int InterrogateDatabase::_current_minor_version = 1;
int InterrogateDatabase::_current_minor_version = 2;
/**
*

View File

@ -24,6 +24,8 @@ InterrogateElement(InterrogateModuleDef *def) :
_setter = 0;
_has_function = 0;
_clear_function = 0;
_del_function = 0;
_length_function = 0;
}
/**
@ -48,6 +50,8 @@ operator = (const InterrogateElement &copy) {
_setter = copy._setter;
_has_function = copy._has_function;
_clear_function = copy._clear_function;
_del_function = copy._del_function;
_length_function = copy._length_function;
}
/**
@ -163,6 +167,38 @@ get_clear_function() const {
return _clear_function;
}
/**
*
*/
INLINE bool InterrogateElement::
has_del_function() const {
return (_flags & F_has_del_function) != 0;
}
/**
*
*/
INLINE FunctionIndex InterrogateElement::
get_del_function() const {
return _del_function;
}
/**
*
*/
INLINE bool InterrogateElement::
is_sequence() const {
return (_flags & F_sequence) != 0;
}
/**
*
*/
INLINE FunctionIndex InterrogateElement::
get_length_function() const {
return _length_function;
}
INLINE ostream &
operator << (ostream &out, const InterrogateElement &element) {

View File

@ -27,7 +27,9 @@ output(ostream &out) const {
<< _getter << " "
<< _setter << " "
<< _has_function << " "
<< _clear_function << " ";
<< _clear_function << " "
<< _del_function << " "
<< _length_function << " ";
idf_output_string(out, _scoped_name);
idf_output_string(out, _comment, '\n');
}
@ -41,6 +43,9 @@ input(istream &in) {
in >> _flags >> _type >> _getter >> _setter;
if (InterrogateDatabase::get_file_minor_version() >= 1) {
in >> _has_function >> _clear_function;
if (InterrogateDatabase::get_file_minor_version() >= 2) {
in >> _del_function >> _length_function;
}
}
idf_input_string(in, _scoped_name);
idf_input_string(in, _comment);
@ -55,4 +60,8 @@ remap_indices(const IndexRemapper &remap) {
_type = remap.map_from(_type);
_getter = remap.map_from(_getter);
_setter = remap.map_from(_setter);
_has_function = remap.map_from(_has_function);
_clear_function = remap.map_from(_clear_function);
_del_function = remap.map_from(_del_function);
_length_function = remap.map_from(_length_function);
}

View File

@ -47,6 +47,10 @@ public:
INLINE FunctionIndex get_has_function() const;
INLINE bool has_clear_function() const;
INLINE FunctionIndex get_clear_function() const;
INLINE bool has_del_function() const;
INLINE FunctionIndex get_del_function() const;
INLINE bool is_sequence() const;
INLINE FunctionIndex get_length_function() const;
void output(ostream &out) const;
void input(istream &in);
@ -60,16 +64,21 @@ private:
F_has_setter = 0x0004,
F_has_has_function= 0x0008,
F_has_clear_function= 0x0010,
F_has_del_function= 0x0020,
F_sequence = 0x0040,
F_mapping = 0x0080,
};
int _flags;
string _scoped_name;
string _comment;
TypeIndex _type;
FunctionIndex _length_function;
FunctionIndex _getter;
FunctionIndex _setter;
FunctionIndex _has_function;
FunctionIndex _clear_function;
FunctionIndex _del_function;
friend class InterrogateBuilder;
};

View File

@ -205,6 +205,14 @@ is_enum() const {
return (_flags & F_enum) != 0;
}
/**
* Returns true if enum values are only available under a scope.
*/
INLINE bool InterrogateType::
is_scoped_enum() const {
return (_flags & F_scoped_enum) != 0;
}
/**
*
*/

View File

@ -65,6 +65,7 @@ public:
INLINE int get_array_size() const;
INLINE bool is_enum() const;
INLINE bool is_scoped_enum() const;
INLINE int number_of_enum_values() const;
INLINE const string &get_enum_value_name(int n) const;
INLINE const string &get_enum_value_scoped_name(int n) const;
@ -136,6 +137,7 @@ private:
F_unpublished = 0x100000,
F_typedef = 0x200000,
F_array = 0x400000,
F_scoped_enum = 0x800000,
};
public:

View File

@ -0,0 +1,219 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file py_panda.I
* @author rdb
* @date 2016-06-06
*/
/**
* Template function that can be used to extract any TypedObject pointer from
* a wrapped Python object.
*/
template<class T> INLINE bool
DTOOL_Call_ExtractThisPointer(PyObject *self, T *&into) {
if (DtoolCanThisBeAPandaInstance(self)) {
Dtool_PyTypedObject *target_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
if (target_class != NULL) {
into = (T*) ((Dtool_PyInstDef *)self)->_My_Type->_Dtool_UpcastInterface(self, target_class);
return (into != NULL);
}
}
into = NULL;
return false;
}
/**
* These functions wrap a pointer for a class that defines get_type_handle().
*/
template<class T> INLINE PyObject *
DTool_CreatePyInstance(const T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, true);
}
template<class T> INLINE PyObject *
DTool_CreatePyInstance(T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, false);
}
template<class T> INLINE PyObject *
DTool_CreatePyInstanceTyped(const T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, true, obj->get_type().get_index());
}
template<class T> INLINE PyObject *
DTool_CreatePyInstanceTyped(T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, false, obj->get_type().get_index());
}
/**
* The following functions wrap an arbitrary C++ value into a PyObject.
*/
ALWAYS_INLINE PyObject *Dtool_WrapValue(int value) {
#if PY_MAJOR_VERSION >= 3
return PyLong_FromLong((long)value);
#else
return PyInt_FromLong((long)value);
#endif
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(unsigned int value) {
#if PY_MAJOR_VERSION >= 3 && SIZEOF_INT < SIZEOF_LONG
return PyLong_FromLong((long)value);
#elif PY_MAJOR_VERSION >= 3
return PyLong_FromUnsignedLong((unsigned long)value);
#elif SIZEOF_INT < SIZEOF_LONG
return PyInt_FromLong((long)value);
#else
return (value > LONG_MAX)
? PyLong_FromUnsignedLong((unsigned long)value)
: PyInt_FromLong((long)value);
#endif
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(long value) {
#if PY_MAJOR_VERSION >= 3
return PyLong_FromLong(value);
#else
return PyInt_FromLong(value);
#endif
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(unsigned long value) {
#if PY_MAJOR_VERSION >= 3
return PyLong_FromUnsignedLong(value);
#else
return (value > LONG_MAX)
? PyLong_FromUnsignedLong(value)
: PyInt_FromLong((long)value);
#endif
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(long long value) {
return PyLong_FromLongLong(value);
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(unsigned long long value) {
return PyLong_FromUnsignedLongLong(value);
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(bool value) {
PyObject *result = (value ? Py_True : Py_False);
Py_INCREF(result);
return result;
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(double value) {
return PyFloat_FromDouble(value);
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(const char *value) {
if (value == (const char *)NULL) {
Py_INCREF(Py_None);
return Py_None;
} else {
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromString(value);
#else
return PyString_FromString(value);
#endif
}
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(const wchar_t *value) {
if (value == (const wchar_t *)NULL) {
Py_INCREF(Py_None);
return Py_None;
} else {
return PyUnicode_FromWideChar(value, (Py_ssize_t)wcslen(value));
}
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string &value) {
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromStringAndSize(value.data(), (Py_ssize_t)value.length());
#else
return PyString_FromStringAndSize(value.data(), (Py_ssize_t)value.length());
#endif
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring &value) {
return PyUnicode_FromWideChar(value.data(), (Py_ssize_t)value.length());
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value) {
if (value == (const std::string *)NULL) {
Py_INCREF(Py_None);
return Py_None;
} else {
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromStringAndSize(value->data(), (Py_ssize_t)value->length());
#else
return PyString_FromStringAndSize(value->data(), (Py_ssize_t)value->length());
#endif
}
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring *value) {
if (value == (const std::wstring *)NULL) {
Py_INCREF(Py_None);
return Py_None;
} else {
return PyUnicode_FromWideChar(value->data(), (Py_ssize_t)value->length());
}
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(char value) {
#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromStringAndSize(&value, 1);
#else
return PyString_FromStringAndSize(&value, 1);
#endif
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(wchar_t value) {
return PyUnicode_FromWideChar(&value, 1);
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(PyObject *value) {
return value;
}
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::vector<unsigned char> &value) {
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size());
#else
return PyString_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size());
#endif
}
#if PY_MAJOR_VERSION >= 0x02060000
ALWAYS_INLINE PyObject *Dtool_WrapValue(Py_buffer *value) {
if (value == (Py_buffer *)NULL) {
return value;
} else {
return PyMemoryView_FromBuffer(value);
}
}
#endif
template<class T1, class T2>
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::pair<T1, T2> &value) {
PyObject *tuple = PyTuple_New(2);
PyTuple_SET_ITEM(tuple, 0, Dtool_WrapValue(value.first));
PyTuple_SET_ITEM(tuple, 1, Dtool_WrapValue(value.second));
return tuple;
}

View File

@ -335,6 +335,33 @@ PyObject *_Dtool_Return(PyObject *value) {
return value;
}
/**
* Creates a Python 3.4-style enum type. Steals reference to 'names'.
*/
PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) {
static PyObject *enum_class = NULL;
static PyObject *enum_meta = NULL;
static PyObject *enum_create = NULL;
if (enum_meta == NULL) {
PyObject *enum_module = PyImport_ImportModule("enum");
nassertr_always(enum_module != NULL, NULL);
enum_class = PyObject_GetAttrString(enum_module, "Enum");
enum_meta = PyObject_GetAttrString(enum_module, "EnumMeta");
enum_create = PyObject_GetAttrString(enum_meta, "_create_");
nassertr(enum_meta != NULL, NULL);
}
PyObject *result = PyObject_CallFunction(enum_create, (char *)"OsN", enum_class, name, names);
nassertr(result != NULL, NULL);
if (module != NULL) {
PyObject *modstr = PyUnicode_FromString(module);
PyObject_SetAttrString(result, "__module__", modstr);
Py_DECREF(modstr);
}
return result;
}
/**
*/
@ -544,8 +571,19 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) {
return (PyObject *)NULL;
}
// Initialize the base class of everything.
Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(NULL);
// Initialize the types we define in py_panda.
static bool dtool_inited = false;
if (!dtool_inited) {
dtool_inited = true;
if (PyType_Ready(&Dtool_SequenceWrapper_Type) < 0) {
PyErr_SetString(PyExc_TypeError, "PyType_Ready(Dtool_SequenceWrapper)");
return NULL;
}
// Initialize the base class of everything.
Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(NULL);
}
// the module level function inits....
MethodDefmap functions;
@ -834,18 +872,106 @@ PyObject *map_deepcopy_to_copy(PyObject *self, PyObject *args) {
}
/**
* Similar to PyLong_FromUnsignedLong(), but returns either a regular integer
* or a long integer, according to whether the indicated value will fit.
* This class is returned from properties that require a settable interface,
* ie. something.children[i] = 3.
*/
#if PY_MAJOR_VERSION < 3
EXPCL_INTERROGATEDB PyObject *
PyLongOrInt_FromUnsignedLong(unsigned long value) {
if ((long)value < 0) {
return PyLong_FromUnsignedLong(value);
} else {
return PyInt_FromLong((long)value);
}
static void Dtool_SequenceWrapper_dealloc(PyObject *self) {
Dtool_SequenceWrapper *wrap = (Dtool_SequenceWrapper *)self;
nassertv(wrap);
Py_DECREF(wrap->_base);
}
static Py_ssize_t Dtool_SequenceWrapper_length(PyObject *self) {
Dtool_SequenceWrapper *wrap = (Dtool_SequenceWrapper *)self;
nassertr(wrap, -1);
nassertr(wrap->_len_func, -1);
return wrap->_len_func(wrap->_base);
}
static PyObject *Dtool_SequenceWrapper_getitem(PyObject *self, Py_ssize_t index) {
Dtool_SequenceWrapper *wrap = (Dtool_SequenceWrapper *)self;
nassertr(wrap, NULL);
nassertr(wrap->_getitem_func, NULL);
return wrap->_getitem_func(wrap->_base, index);
}
static int Dtool_SequenceWrapper_setitem(PyObject *self, Py_ssize_t index, PyObject *value) {
Dtool_SequenceWrapper *wrap = (Dtool_SequenceWrapper *)self;
nassertr(wrap, -1);
nassertr(wrap->_setitem_func, -1);
return wrap->_setitem_func(wrap->_base, index, value);
}
static PySequenceMethods Dtool_SequenceWrapper_SequenceMethods = {
Dtool_SequenceWrapper_length,
0, // sq_concat
0, // sq_repeat
Dtool_SequenceWrapper_getitem,
0, // sq_slice
Dtool_SequenceWrapper_setitem,
0, // sq_ass_slice
0, // sq_contains
0, // sq_inplace_concat
0, // sq_inplace_repeat
};
PyTypeObject Dtool_SequenceWrapper_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"sequence wrapper",
sizeof(Dtool_SequenceWrapper),
0, // tp_itemsize
Dtool_SequenceWrapper_dealloc,
0, // tp_print
0, // tp_getattr
0, // tp_setattr
#if PY_MAJOR_VERSION >= 3
0, // tp_reserved
#else
0, // tp_compare
#endif
0, // tp_repr
0, // tp_as_number
&Dtool_SequenceWrapper_SequenceMethods,
0, // tp_as_mapping
0, // tp_hash
0, // tp_call
0, // tp_str
PyObject_GenericGetAttr,
PyObject_GenericSetAttr,
0, // tp_as_buffer
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES,
0, // tp_doc
0, // tp_traverse
0, // tp_clear
0, // tp_richcompare
0, // tp_weaklistoffset
0, // tp_iter
0, // tp_iternext
0, // 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
0, // tp_init
PyType_GenericAlloc,
0, // tp_new
PyObject_Del,
0, // tp_is_gc
0, // tp_bases
0, // tp_mro
0, // tp_cache
0, // tp_subclasses
0, // tp_weaklist
0, // tp_del
#if PY_VERSION_HEX >= 0x02060000
0, // tp_version_tag
#endif
#if PY_VERSION_HEX >= 0x03040000
0, // tp_finalize
#endif
};
#endif // HAVE_PYTHON

View File

@ -103,10 +103,6 @@ inline PyObject* doPy_RETURN_FALSE()
#define nb_inplace_divide nb_inplace_true_divide
#define PyLongOrInt_Check(x) PyLong_Check(x)
#define PyLongOrInt_FromSize_t PyLong_FromSize_t
#define PyLongOrInt_FromSsize_t PyLong_FromSsize_t
#define PyLongOrInt_FromLong PyLong_FromLong
#define PyLongOrInt_FromUnsignedLong PyLong_FromUnsignedLong
#define PyLongOrInt_AS_LONG PyLong_AS_LONG
#define PyInt_Check PyLong_Check
#define PyInt_AsLong PyLong_AsLong
@ -114,9 +110,6 @@ inline PyObject* doPy_RETURN_FALSE()
#else
#define PyLongOrInt_Check(x) (PyInt_Check(x) || PyLong_Check(x))
// PyInt_FromSize_t automatically picks the right type.
#define PyLongOrInt_FromSize_t PyInt_FromSize_t
#define PyLongOrInt_FromSsize_t PyInt_FromSsize_t
#define PyLongOrInt_FromLong PyInt_FromLong
#define PyLongOrInt_AS_LONG PyInt_AsLong
// For more portably defining hash functions.
@ -159,9 +152,6 @@ typedef void *(*DowncastFunction)(void *, Dtool_PyTypedObject *);
typedef void *(*CoerceFunction)(PyObject *, void *);
typedef void (*ModuleClassInitFunction)(PyObject *module);
// inline Dtool_PyTypedObject * Dtool_RuntimeTypeDtoolType(int
// type); inline void Dtool_Deallocate_General(PyObject * self); inline
// int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2); THIS IS THE
// INSTANCE CONTAINER FOR ALL panda py objects....
struct Dtool_PyInstDef {
PyObject_HEAD
@ -300,17 +290,7 @@ EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyT
EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef,
void **answer, const char *method_name);
template<class T> INLINE bool DTOOL_Call_ExtractThisPointer(PyObject *self, T *&into) {
if (DtoolCanThisBeAPandaInstance(self)) {
Dtool_PyTypedObject *target_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
if (target_class != NULL) {
into = (T*) ((Dtool_PyInstDef *)self)->_My_Type->_Dtool_UpcastInterface(self, target_class);
return (into != NULL);
}
}
into = NULL;
return false;
}
template<class T> INLINE bool DTOOL_Call_ExtractThisPointer(PyObject *self, T *&into);
// Functions related to error reporting.
EXPCL_INTERROGATEDB bool _Dtool_CheckErrorOccurred();
@ -348,6 +328,12 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value);
#define Dtool_Return(value) _Dtool_Return(value)
#endif
/**
* Wrapper around Python 3.4's enum library, which does not have a C API.
*/
EXPCL_INTERROGATEDB PyObject *Dtool_EnumType_Create(const char *name, PyObject *names,
const char *module = NULL);
/**
*/
@ -359,29 +345,10 @@ EXPCL_INTERROGATEDB PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyT
// These template methods allow use when the Dtool_PyTypedObject is not known.
// They require a get_class_type() to be defined for the class.
template<class T> INLINE PyObject *DTool_CreatePyInstance(const T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, true);
}
template<class T> INLINE PyObject *DTool_CreatePyInstance(T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, false);
}
template<class T> INLINE PyObject *DTool_CreatePyInstanceTyped(const T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, true, obj->get_type().get_index());
}
template<class T> INLINE PyObject *DTool_CreatePyInstanceTyped(T *obj, bool memory_rules) {
Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index());
nassertr(known_class != NULL, NULL);
return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, false, obj->get_type().get_index());
}
template<class T> INLINE PyObject *DTool_CreatePyInstance(const T *obj, bool memory_rules);
template<class T> INLINE PyObject *DTool_CreatePyInstance(T *obj, bool memory_rules);
template<class T> INLINE PyObject *DTool_CreatePyInstanceTyped(const T *obj, bool memory_rules);
template<class T> INLINE PyObject *DTool_CreatePyInstanceTyped(T *obj, bool memory_rules);
// Macro(s) class definition .. Used to allocate storage and init some values
// for a Dtool Py Type object.
@ -474,18 +441,59 @@ copy_from_copy_constructor(PyObject *self, PyObject *noargs);
EXPCL_INTERROGATEDB PyObject *
map_deepcopy_to_copy(PyObject *self, PyObject *args);
#if PY_MAJOR_VERSION < 3
// In the Python 3 case, it is defined as a macro, at the beginning of this
// file.
EXPCL_INTERROGATEDB PyObject *
PyLongOrInt_FromUnsignedLong(unsigned long value);
/**
* This class is returned from properties that require a settable interface,
* ie. something.children[i] = 3.
*/
struct Dtool_SequenceWrapper {
PyObject_HEAD
PyObject *_base;
lenfunc _len_func;
ssizeargfunc _getitem_func;
ssizeobjargproc _setitem_func;
};
EXPCL_INTERROGATEDB extern PyTypeObject Dtool_SequenceWrapper_Type;
/**
* These functions convert a C++ value into the corresponding Python object.
* This used to be generated by the code generator, but it seems more reliable
* and maintainable to define these as overloads and have the compiler sort
* it out.
*/
ALWAYS_INLINE PyObject *Dtool_WrapValue(int value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(unsigned int value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(long value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(unsigned long value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(long long value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(unsigned long long value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(bool value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(double value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(const char *value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(const wchar_t *value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string &value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring &value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring *value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(char value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(wchar_t value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(PyObject *value);
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::vector<unsigned char> &value);
#if PY_MAJOR_VERSION >= 0x02060000
ALWAYS_INLINE PyObject *Dtool_WrapValue(Py_buffer *value);
#endif
template<class T1, class T2>
ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::pair<T1, T2> &value);
EXPCL_INTERROGATEDB extern struct Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE;
EXPCL_INTERROGATEDB extern void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module);
#define Dtool_Ptr_DTOOL_SUPER_BASE (&Dtool_DTOOL_SUPER_BASE)
#include "py_panda.I"
#endif // HAVE_PYTHON && !CPPPARSER
#endif // PY_PANDA_H_

View File

@ -187,7 +187,7 @@ get_int_word(size_t n) const {
* Returns the int64 value of the nth word of the declaration's value, or 0 if
* there is no nth value. See also has_int64_word().
*/
INLINE PN_int64 ConfigDeclaration::
INLINE int64_t ConfigDeclaration::
get_int64_word(size_t n) const {
// We use has_string_word() instead of has_int64_word(), so we can return a
// partial answer if there was one.

View File

@ -108,7 +108,7 @@ set_int_word(size_t n, int value) {
* words.
*/
void ConfigDeclaration::
set_int64_word(size_t n, PN_int64 value) {
set_int64_word(size_t n, int64_t value) {
set_string_word(n, format_string(value));
_words[n]._flags |= (F_checked_int64 | F_valid_int64);
@ -294,8 +294,8 @@ check_int64_word(size_t n) {
++pi;
// Negative number.
while (pi != word._str.end() && isdigit(*pi)) {
PN_int64 next = word._int_64 * 10 - (int)((*pi) - '0');
if ((PN_int64)(next / 10) != word._int_64) {
int64_t next = word._int_64 * 10 - (int)((*pi) - '0');
if ((int64_t)(next / 10) != word._int_64) {
// Overflow.
overflow = true;
}
@ -306,8 +306,8 @@ check_int64_word(size_t n) {
} else {
// Positive number.
while (pi != word._str.end() && isdigit(*pi)) {
PN_int64 next = word._int_64 * 10 + (int)((*pi) - '0');
if ((PN_int64)(next / 10) != word._int_64) {
int64_t next = word._int_64 * 10 + (int)((*pi) - '0');
if ((int64_t)(next / 10) != word._int_64) {
// Overflow.
overflow = true;
}

View File

@ -59,13 +59,13 @@ PUBLISHED:
INLINE string get_string_word(size_t n) const;
INLINE bool get_bool_word(size_t n) const;
INLINE int get_int_word(size_t n) const;
INLINE PN_int64 get_int64_word(size_t n) const;
INLINE int64_t get_int64_word(size_t n) const;
INLINE double get_double_word(size_t n) const;
void set_string_word(size_t n, const string &value);
void set_bool_word(size_t n, bool value);
void set_int_word(size_t n, int value);
void set_int64_word(size_t n, PN_int64 value);
void set_int64_word(size_t n, int64_t value);
void set_double_word(size_t n, double value);
INLINE int get_decl_seq() const;
@ -106,7 +106,7 @@ private:
string _str;
bool _bool;
int _int;
PN_int64 _int_64;
int64_t _int_64;
double _double;
short _flags;
};

View File

@ -44,6 +44,8 @@ PUBLISHED:
INLINE bool is_special() const;
INLINE bool is_implicit() const;
MAKE_PROPERTY(special, is_special);
MAKE_PROPERTY(implicit, is_implicit);
void set_sort(int sort);
INLINE int get_sort() const;
@ -72,6 +74,8 @@ PUBLISHED:
string get_string_value(size_t n) const;
bool is_variable_used(size_t n) const;
MAKE_SEQ_PROPERTY(declarations, get_num_declarations, modify_declaration);
void output(ostream &out) const;
void output_brief_signature(ostream &out) const;
void write(ostream &out) const;

View File

@ -196,7 +196,7 @@ get_int_word(size_t n) const {
* Returns the int64 value of the nth word of the variable's value, or 0 if
* there is no nth value. See also has_int_word().
*/
INLINE PN_int64 ConfigVariable::
INLINE int64_t ConfigVariable::
get_int64_word(size_t n) const {
nassertr(is_constructed(), 0);
const ConfigDeclaration *decl = _core->get_declaration(0);
@ -249,7 +249,7 @@ set_int_word(size_t n, int value) {
* words.
*/
INLINE void ConfigVariable::
set_int64_word(size_t n, PN_int64 value) {
set_int64_word(size_t n, int64_t value) {
nassertv(is_constructed());
_core->make_local_value()->set_int64_word(n, value);
}

View File

@ -56,13 +56,13 @@ protected:
INLINE string get_string_word(size_t n) const;
INLINE bool get_bool_word(size_t n) const;
INLINE int get_int_word(size_t n) const;
INLINE PN_int64 get_int64_word(size_t n) const;
INLINE int64_t get_int64_word(size_t n) const;
INLINE double get_double_word(size_t n) const;
INLINE void set_string_word(size_t n, const string &value);
INLINE void set_bool_word(size_t n, bool value);
INLINE void set_int_word(size_t n, int value);
INLINE void set_int64_word(size_t n, PN_int64 value);
INLINE void set_int64_word(size_t n, int64_t value);
INLINE void set_double_word(size_t n, double value);
protected:

View File

@ -75,10 +75,25 @@ PUBLISHED:
INLINE size_t get_num_unique_references() const;
INLINE const ConfigDeclaration *get_unique_reference(size_t n) const;
MAKE_SEQ(get_unique_references, get_num_unique_references, get_unique_reference);
MAKE_SEQ_PROPERTY(declarations, get_num_declarations, get_declaration);
void output(ostream &out) const;
void write(ostream &out) const;
MAKE_PROPERTY(name, get_name);
MAKE_PROPERTY(used, is_used);
MAKE_PROPERTY(closed, is_closed);
MAKE_PROPERTY(trust_level, get_trust_level);
MAKE_PROPERTY(dynamic, is_dynamic);
MAKE_PROPERTY(value_type, get_value_type, set_value_type);
MAKE_PROPERTY(description, get_description, set_description);
MAKE_PROPERTY(default_value, get_default_value, set_default_value);
MAKE_SEQ_PROPERTY(references, get_num_references, get_reference);
MAKE_SEQ_PROPERTY(trusted_references, get_num_trusted_references, get_trusted_reference);
MAKE_SEQ_PROPERTY(unique_references, get_num_unique_references, get_unique_reference);
private:
void add_declaration(ConfigDeclaration *decl);
void remove_declaration(ConfigDeclaration *decl);

View File

@ -26,7 +26,7 @@ ConfigVariableInt64(const string &name) :
*
*/
INLINE ConfigVariableInt64::
ConfigVariableInt64(const string &name, PN_int64 default_value,
ConfigVariableInt64(const string &name, int64_t default_value,
const string &description, int flags) :
#ifdef PRC_SAVE_DESCRIPTIONS
ConfigVariable(name, ConfigVariableCore::VT_int64, description, flags),
@ -60,7 +60,7 @@ ConfigVariableInt64(const string &name, const string &default_value,
* Reassigns the variable's local value.
*/
INLINE void ConfigVariableInt64::
operator = (PN_int64 value) {
operator = (int64_t value) {
set_value(value);
}
@ -68,7 +68,7 @@ operator = (PN_int64 value) {
* Returns the variable's value.
*/
INLINE ConfigVariableInt64::
operator PN_int64 () const {
operator int64_t () const {
return get_value();
}
@ -83,7 +83,7 @@ size() const {
/**
* Returns the value of the variable's nth word.
*/
INLINE PN_int64 ConfigVariableInt64::
INLINE int64_t ConfigVariableInt64::
operator [] (size_t n) const {
return get_word(n);
}
@ -92,7 +92,7 @@ operator [] (size_t n) const {
* Reassigns the variable's local value.
*/
INLINE void ConfigVariableInt64::
set_value(PN_int64 value) {
set_value(int64_t value) {
set_string_value("");
set_int64_word(0, value);
}
@ -100,9 +100,9 @@ set_value(PN_int64 value) {
/**
* Returns the variable's value.
*/
INLINE PN_int64 ConfigVariableInt64::
INLINE int64_t ConfigVariableInt64::
get_value() const {
TAU_PROFILE("PN_int64 ConfigVariableInt64::get_value() const", " ", TAU_USER);
TAU_PROFILE("int64_t ConfigVariableInt64::get_value() const", " ", TAU_USER);
if (!is_cache_valid(_local_modified)) {
mark_cache_valid(((ConfigVariableInt64 *)this)->_local_modified);
((ConfigVariableInt64 *)this)->_cache = get_int64_word(0);
@ -113,7 +113,7 @@ get_value() const {
/**
* Returns the variable's default value.
*/
INLINE PN_int64 ConfigVariableInt64::
INLINE int64_t ConfigVariableInt64::
get_default_value() const {
const ConfigDeclaration *decl = ConfigVariable::get_default_value();
if (decl != (ConfigDeclaration *)NULL) {
@ -125,7 +125,7 @@ get_default_value() const {
/**
* Returns the variable's nth value.
*/
INLINE PN_int64 ConfigVariableInt64::
INLINE int64_t ConfigVariableInt64::
get_word(size_t n) const {
return get_int64_word(n);
}
@ -135,6 +135,6 @@ get_word(size_t n) const {
* variable's overall value.
*/
INLINE void ConfigVariableInt64::
set_word(size_t n, PN_int64 value) {
set_word(size_t n, int64_t value) {
set_int64_word(n, value);
}

View File

@ -18,6 +18,6 @@
*
*/
void ConfigVariableInt64::
set_default_value(PN_int64 default_value) {
set_default_value(int64_t default_value) {
_core->set_default_value(format_string(default_value));
}

View File

@ -25,34 +25,34 @@
class EXPCL_DTOOLCONFIG ConfigVariableInt64 : public ConfigVariable {
PUBLISHED:
INLINE ConfigVariableInt64(const string &name);
INLINE ConfigVariableInt64(const string &name, PN_int64 default_value,
INLINE ConfigVariableInt64(const string &name, int64_t default_value,
const string &description = string(),
int flags = 0);
INLINE ConfigVariableInt64(const string &name, const string &default_value,
const string &description = string(),
int flags = 0);
INLINE void operator = (PN_int64 value);
INLINE operator PN_int64 () const;
INLINE void operator = (int64_t value);
INLINE operator int64_t () const;
INLINE size_t size() const;
INLINE PN_int64 operator [] (size_t n) const;
INLINE int64_t operator [] (size_t n) const;
INLINE void set_value(PN_int64 value);
INLINE PN_int64 get_value() const;
INLINE PN_int64 get_default_value() const;
INLINE void set_value(int64_t value);
INLINE int64_t get_value() const;
INLINE int64_t get_default_value() const;
MAKE_PROPERTY(value, get_value, set_value);
MAKE_PROPERTY(default_value, get_default_value);
INLINE PN_int64 get_word(size_t n) const;
INLINE void set_word(size_t n, PN_int64 value);
INLINE int64_t get_word(size_t n) const;
INLINE void set_word(size_t n, int64_t value);
private:
void set_default_value(PN_int64 default_value);
void set_default_value(int64_t default_value);
private:
AtomicAdjust::Integer _local_modified;
PN_int64 _cache;
int64_t _cache;
};
#include "configVariableInt64.I"

View File

@ -48,6 +48,8 @@ PUBLISHED:
string get_variable_name(size_t n) const;
bool is_variable_used(size_t n) const;
MAKE_SEQ_PROPERTY(variables, get_num_variables, get_variable);
void output(ostream &out) const;
void write(ostream &out) const;

View File

@ -68,6 +68,7 @@ PUBLISHED:
INLINE size_t get_num_directories() const;
INLINE const Filename &get_directory(size_t n) const;
MAKE_SEQ(get_directories, get_num_directories, get_directory);
MAKE_SEQ_PROPERTY(directories, get_num_directories, get_directory);
INLINE Filename find_file(const Filename &filename) const;
INLINE size_t find_all_files(const Filename &filename,

View File

@ -109,6 +109,29 @@ close() {
return *this;
}
/**
* Returns the encryption algorithm that was read from the stream.
*/
INLINE const string &OEncryptStream::
get_algorithm() const {
return _buf.get_algorithm();
}
/**
* Returns the encryption key length, in bits, that was read from the stream.
*/
INLINE int OEncryptStream::
get_key_length() const {
return _buf.get_key_length();
}
/**
* Returns the value that was was read from the stream.
*/
INLINE int OEncryptStream::
get_iteration_count() const {
return _buf.get_iteration_count();
}
/**
* Specifies the encryption algorithm that should be used for future calls to

View File

@ -49,6 +49,10 @@ PUBLISHED:
INLINE int get_key_length() const;
INLINE int get_iteration_count() const;
MAKE_PROPERTY(algorithm, get_algorithm);
MAKE_PROPERTY(key_length, get_key_length);
MAKE_PROPERTY(iteration_count, get_iteration_count);
private:
EncryptStreamBuf _buf;
};
@ -76,10 +80,20 @@ PUBLISHED:
const string &password);
INLINE OEncryptStream &close();
public:
INLINE const string &get_algorithm() const;
INLINE int get_key_length() const;
INLINE int get_iteration_count() const;
PUBLISHED:
INLINE void set_algorithm(const string &algorithm);
INLINE void set_key_length(int key_length);
INLINE void set_iteration_count(int iteration_count);
MAKE_PROPERTY(algorithm, get_algorithm, set_algorithm);
MAKE_PROPERTY(key_length, get_key_length, set_key_length);
MAKE_PROPERTY(iteration_count, get_iteration_count, set_iteration_count);
private:
EncryptStreamBuf _buf;
};

View File

@ -276,12 +276,12 @@ open_write(ostream *dest, bool owns_dest, const string &password) {
// Now write the header information to the stream.
StreamWriter sw(_dest, false);
nassertv((PN_uint16)nid == nid);
sw.add_uint16((PN_uint16)nid);
nassertv((PN_uint16)key_length == key_length);
sw.add_uint16((PN_uint16)key_length);
nassertv((PN_uint16)count == count);
sw.add_uint16((PN_uint16)count);
nassertv((uint16_t)nid == nid);
sw.add_uint16((uint16_t)nid);
nassertv((uint16_t)key_length == key_length);
sw.add_uint16((uint16_t)key_length);
nassertv((uint16_t)count == count);
sw.add_uint16((uint16_t)count);
sw.append_data(iv, iv_length);
_write_valid = true;

View File

@ -54,24 +54,24 @@ get_data() const {
// this is for a intel compile .. it is native format and it is readable off
// word boundries
inline void TS_SetVal1(const PN_int8 * src, PN_int8 *dst)
inline void TS_SetVal1(const int8_t * src, int8_t *dst)
{
*dst = *src;
}
inline void TS_SetVal2(const char * src, char *dst)
{
*(reinterpret_cast<PN_int16 *>(dst)) = *(reinterpret_cast <const PN_int16 *>(src));
*(reinterpret_cast<int16_t *>(dst)) = *(reinterpret_cast <const int16_t *>(src));
}
inline void TS_SetVal4(const char * src, char *dst)
{
*(reinterpret_cast <PN_int32 *>(dst)) = *(reinterpret_cast <const PN_int32 *>(src));
*(reinterpret_cast <int32_t *>(dst)) = *(reinterpret_cast <const int32_t *>(src));
}
inline void TS_SetVal8(const char * src, char *dst)
{
*(reinterpret_cast<PN_int64 *>(dst)) = *(reinterpret_cast<const PN_int64 *>(src));
*(reinterpret_cast<int64_t *>(dst)) = *(reinterpret_cast<const int64_t *>(src));
}
template<class type> inline type TS_GetInteger(type &val,const char * _src)

View File

@ -74,6 +74,7 @@ PUBLISHED:
size_t get_num_children() const;
NotifyCategory *get_child(size_t i) const;
MAKE_SEQ(get_children, get_num_children, get_child);
MAKE_SEQ_PROPERTY(children, get_num_children, get_child);
static void set_server_delta(long delta);

View File

@ -83,25 +83,25 @@ get_bool() {
/**
* Extracts a signed 8-bit integer.
*/
INLINE PN_int8 StreamReader::
INLINE int8_t StreamReader::
get_int8() {
return (PN_int8)_in->get();
return (int8_t)_in->get();
}
/**
* Extracts an unsigned 8-bit integer.
*/
INLINE PN_uint8 StreamReader::
INLINE uint8_t StreamReader::
get_uint8() {
return (PN_uint8)_in->get();
return (uint8_t)_in->get();
}
/**
* Extracts a signed 16-bit integer.
*/
INLINE PN_int16 StreamReader::
INLINE int16_t StreamReader::
get_int16() {
PN_int16 readval, retval;
int16_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
LittleEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -111,9 +111,9 @@ get_int16() {
/**
* Extracts a signed 32-bit integer.
*/
INLINE PN_int32 StreamReader::
INLINE int32_t StreamReader::
get_int32() {
PN_int32 readval, retval;
int32_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
LittleEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -123,9 +123,9 @@ get_int32() {
/**
* Extracts a signed 64-bit integer.
*/
INLINE PN_int64 StreamReader::
INLINE int64_t StreamReader::
get_int64() {
PN_int64 readval, retval;
int64_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
LittleEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -135,9 +135,9 @@ get_int64() {
/**
* Extracts an unsigned 16-bit integer.
*/
INLINE PN_uint16 StreamReader::
INLINE uint16_t StreamReader::
get_uint16() {
PN_uint16 readval, retval;
uint16_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
LittleEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -147,9 +147,9 @@ get_uint16() {
/**
* Extracts an unsigned 32-bit integer.
*/
INLINE PN_uint32 StreamReader::
INLINE uint32_t StreamReader::
get_uint32() {
PN_uint32 readval, retval;
uint32_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
LittleEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -159,9 +159,9 @@ get_uint32() {
/**
* Extracts an unsigned 64-bit integer.
*/
INLINE PN_uint64 StreamReader::
INLINE uint64_t StreamReader::
get_uint64() {
PN_uint64 readval, retval;
uint64_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
LittleEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -202,9 +202,9 @@ get_float64() {
/**
* Extracts a signed big-endian 16-bit integer.
*/
INLINE PN_int16 StreamReader::
INLINE int16_t StreamReader::
get_be_int16() {
PN_int16 readval, retval;
int16_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
BigEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -214,9 +214,9 @@ get_be_int16() {
/**
* Extracts a signed big-endian 32-bit integer.
*/
INLINE PN_int32 StreamReader::
INLINE int32_t StreamReader::
get_be_int32() {
PN_int32 readval, retval;
int32_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
BigEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -226,9 +226,9 @@ get_be_int32() {
/**
* Extracts a signed big-endian 64-bit integer.
*/
INLINE PN_int64 StreamReader::
INLINE int64_t StreamReader::
get_be_int64() {
PN_int64 readval, retval;
int64_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
BigEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -238,9 +238,9 @@ get_be_int64() {
/**
* Extracts an unsigned big-endian 16-bit integer.
*/
INLINE PN_uint16 StreamReader::
INLINE uint16_t StreamReader::
get_be_uint16() {
PN_uint16 readval, retval;
uint16_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
BigEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -250,9 +250,9 @@ get_be_uint16() {
/**
* Extracts an unsigned big-endian 32-bit integer.
*/
INLINE PN_uint32 StreamReader::
INLINE uint32_t StreamReader::
get_be_uint32() {
PN_uint32 readval, retval;
uint32_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
BigEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));
@ -262,9 +262,9 @@ get_be_uint32() {
/**
* Extracts an unsigned big-endian 64-bit integer.
*/
INLINE PN_uint64 StreamReader::
INLINE uint64_t StreamReader::
get_be_uint64() {
PN_uint64 readval, retval;
uint64_t readval, retval;
_in->read((char *)&readval, sizeof(readval));
BigEndian s(&readval, 0, sizeof(readval));
s.store_value(&retval, sizeof(retval));

View File

@ -34,26 +34,27 @@ PUBLISHED:
INLINE ~StreamReader();
INLINE istream *get_istream() const;
MAKE_PROPERTY(istream, get_istream);
BLOCKING INLINE bool get_bool();
BLOCKING INLINE PN_int8 get_int8();
BLOCKING INLINE PN_uint8 get_uint8();
BLOCKING INLINE int8_t get_int8();
BLOCKING INLINE uint8_t get_uint8();
BLOCKING INLINE PN_int16 get_int16();
BLOCKING INLINE PN_int32 get_int32();
BLOCKING INLINE PN_int64 get_int64();
BLOCKING INLINE PN_uint16 get_uint16();
BLOCKING INLINE PN_uint32 get_uint32();
BLOCKING INLINE PN_uint64 get_uint64();
BLOCKING INLINE int16_t get_int16();
BLOCKING INLINE int32_t get_int32();
BLOCKING INLINE int64_t get_int64();
BLOCKING INLINE uint16_t get_uint16();
BLOCKING INLINE uint32_t get_uint32();
BLOCKING INLINE uint64_t get_uint64();
BLOCKING INLINE float get_float32();
BLOCKING INLINE PN_float64 get_float64();
BLOCKING INLINE PN_int16 get_be_int16();
BLOCKING INLINE PN_int32 get_be_int32();
BLOCKING INLINE PN_int64 get_be_int64();
BLOCKING INLINE PN_uint16 get_be_uint16();
BLOCKING INLINE PN_uint32 get_be_uint32();
BLOCKING INLINE PN_uint64 get_be_uint64();
BLOCKING INLINE int16_t get_be_int16();
BLOCKING INLINE int32_t get_be_int32();
BLOCKING INLINE int64_t get_be_int64();
BLOCKING INLINE uint16_t get_be_uint16();
BLOCKING INLINE uint32_t get_be_uint32();
BLOCKING INLINE uint64_t get_be_uint64();
BLOCKING INLINE float get_be_float32();
BLOCKING INLINE PN_float64 get_be_float64();

View File

@ -53,6 +53,7 @@ PUBLISHED:
~IStreamWrapper();
INLINE istream *get_istream() const;
MAKE_PROPERTY(istream, get_istream);
public:
void read(char *buffer, streamsize num_bytes);
@ -79,6 +80,7 @@ PUBLISHED:
~OStreamWrapper();
INLINE ostream *get_ostream() const;
MAKE_PROPERTY(ostream, get_ostream);
public:
void write(const char *buffer, streamsize num_bytes);
@ -114,6 +116,7 @@ PUBLISHED:
~StreamWrapper();
INLINE iostream *get_iostream() const;
MAKE_PROPERTY(iostream, get_iostream);
private:
iostream *_iostream;

View File

@ -92,7 +92,7 @@ add_bool(bool b) {
* Adds a signed 8-bit integer to the stream.
*/
INLINE void StreamWriter::
add_int8(PN_int8 value) {
add_int8(int8_t value) {
append_data(&value, 1);
}
@ -100,7 +100,7 @@ add_int8(PN_int8 value) {
* Adds an unsigned 8-bit integer to the stream.
*/
INLINE void StreamWriter::
add_uint8(PN_uint8 value) {
add_uint8(uint8_t value) {
append_data(&value, 1);
}
@ -108,7 +108,7 @@ add_uint8(PN_uint8 value) {
* Adds a signed 16-bit integer to the stream.
*/
INLINE void StreamWriter::
add_int16(PN_int16 value) {
add_int16(int16_t value) {
LittleEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -117,7 +117,7 @@ add_int16(PN_int16 value) {
* Adds a signed 32-bit integer to the stream.
*/
INLINE void StreamWriter::
add_int32(PN_int32 value) {
add_int32(int32_t value) {
LittleEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -126,7 +126,7 @@ add_int32(PN_int32 value) {
* Adds a signed 64-bit integer to the stream.
*/
INLINE void StreamWriter::
add_int64(PN_int64 value) {
add_int64(int64_t value) {
LittleEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -135,7 +135,7 @@ add_int64(PN_int64 value) {
* Adds an unsigned 16-bit integer to the stream.
*/
INLINE void StreamWriter::
add_uint16(PN_uint16 value) {
add_uint16(uint16_t value) {
LittleEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -144,7 +144,7 @@ add_uint16(PN_uint16 value) {
* Adds an unsigned 32-bit integer to the stream.
*/
INLINE void StreamWriter::
add_uint32(PN_uint32 value) {
add_uint32(uint32_t value) {
LittleEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -153,7 +153,7 @@ add_uint32(PN_uint32 value) {
* Adds an unsigned 64-bit integer to the stream.
*/
INLINE void StreamWriter::
add_uint64(PN_uint64 value) {
add_uint64(uint64_t value) {
LittleEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -186,7 +186,7 @@ add_float64(PN_float64 value) {
* Adds a signed 16-bit big-endian integer to the streamWriter.
*/
INLINE void StreamWriter::
add_be_int16(PN_int16 value) {
add_be_int16(int16_t value) {
BigEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -195,7 +195,7 @@ add_be_int16(PN_int16 value) {
* Adds a signed 32-bit big-endian integer to the streamWriter.
*/
INLINE void StreamWriter::
add_be_int32(PN_int32 value) {
add_be_int32(int32_t value) {
BigEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -204,7 +204,7 @@ add_be_int32(PN_int32 value) {
* Adds a signed 64-bit big-endian integer to the streamWriter.
*/
INLINE void StreamWriter::
add_be_int64(PN_int64 value) {
add_be_int64(int64_t value) {
BigEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -213,7 +213,7 @@ add_be_int64(PN_int64 value) {
* Adds an unsigned 16-bit big-endian integer to the streamWriter.
*/
INLINE void StreamWriter::
add_be_uint16(PN_uint16 value) {
add_be_uint16(uint16_t value) {
BigEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -222,7 +222,7 @@ add_be_uint16(PN_uint16 value) {
* Adds an unsigned 32-bit big-endian integer to the streamWriter.
*/
INLINE void StreamWriter::
add_be_uint32(PN_uint32 value) {
add_be_uint32(uint32_t value) {
BigEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -231,7 +231,7 @@ add_be_uint32(PN_uint32 value) {
* Adds an unsigned 64-bit big-endian integer to the streamWriter.
*/
INLINE void StreamWriter::
add_be_uint64(PN_uint64 value) {
add_be_uint64(uint64_t value) {
BigEndian s(&value, sizeof(value));
append_data(s.get_data(), sizeof(value));
}
@ -267,10 +267,10 @@ add_be_float64(PN_float64 value) {
INLINE void StreamWriter::
add_string(const string &str) {
// The max sendable length for a string is 2^16.
nassertv(str.length() <= (PN_uint16)0xffff);
nassertv(str.length() <= (uint16_t)0xffff);
// Strings always are preceded by their length
add_uint16((PN_uint16)str.length());
add_uint16((uint16_t)str.length());
// Add the string
append_data(str);
@ -282,7 +282,7 @@ add_string(const string &str) {
INLINE void StreamWriter::
add_string32(const string &str) {
// Strings always are preceded by their length
add_uint32((PN_uint32)str.length());
add_uint32((uint32_t)str.length());
// Add the string
append_data(str);

View File

@ -36,28 +36,29 @@ PUBLISHED:
INLINE ~StreamWriter();
INLINE ostream *get_ostream() const;
MAKE_PROPERTY(ostream, get_ostream);
BLOCKING INLINE void add_bool(bool value);
BLOCKING INLINE void add_int8(PN_int8 value);
BLOCKING INLINE void add_uint8(PN_uint8 value);
BLOCKING INLINE void add_int8(int8_t value);
BLOCKING INLINE void add_uint8(uint8_t value);
// The default numeric packing is little-endian.
BLOCKING INLINE void add_int16(PN_int16 value);
BLOCKING INLINE void add_int32(PN_int32 value);
BLOCKING INLINE void add_int64(PN_int64 value);
BLOCKING INLINE void add_uint16(PN_uint16 value);
BLOCKING INLINE void add_uint32(PN_uint32 value);
BLOCKING INLINE void add_uint64(PN_uint64 value);
BLOCKING INLINE void add_int16(int16_t value);
BLOCKING INLINE void add_int32(int32_t value);
BLOCKING INLINE void add_int64(int64_t value);
BLOCKING INLINE void add_uint16(uint16_t value);
BLOCKING INLINE void add_uint32(uint32_t value);
BLOCKING INLINE void add_uint64(uint64_t value);
BLOCKING INLINE void add_float32(float value);
BLOCKING INLINE void add_float64(PN_float64 value);
// These functions pack numbers big-endian, in case that's desired.
BLOCKING INLINE void add_be_int16(PN_int16 value);
BLOCKING INLINE void add_be_int32(PN_int32 value);
BLOCKING INLINE void add_be_int64(PN_int64 value);
BLOCKING INLINE void add_be_uint16(PN_uint16 value);
BLOCKING INLINE void add_be_uint32(PN_uint32 value);
BLOCKING INLINE void add_be_uint64(PN_uint64 value);
BLOCKING INLINE void add_be_int16(int16_t value);
BLOCKING INLINE void add_be_int32(int32_t value);
BLOCKING INLINE void add_be_int64(int64_t value);
BLOCKING INLINE void add_be_uint16(uint16_t value);
BLOCKING INLINE void add_be_uint32(uint32_t value);
BLOCKING INLINE void add_be_uint64(uint64_t value);
BLOCKING INLINE void add_be_float32(float value);
BLOCKING INLINE void add_be_float64(PN_float64 value);

View File

@ -609,10 +609,14 @@ if (COMPILER == "MSVC"):
else:
LibName("TIFF", GetThirdpartyDir() + "tiff/lib/tiff.lib")
if (PkgSkip("OPENEXR")==0):
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/IlmImf-2_2.lib")
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/IlmThread-2_2.lib")
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/Iex-2_2.lib")
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/Half.lib")
suffix = ""
if os.path.isfile(GetThirdpartyDir() + "openexr/lib/IlmImf-2_2.lib"):
suffix = "-2_2"
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/IlmImf" + suffix + ".lib")
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/IlmThread" + suffix + ".lib")
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/Iex" + suffix + ".lib")
LibName("OPENEXR", GetThirdpartyDir() + "openexr/lib/Half.lib")
IncDirectory("OPENEXR", GetThirdpartyDir() + "openexr/include/OpenEXR")
if (PkgSkip("JPEG")==0): LibName("JPEG", GetThirdpartyDir() + "jpeg/lib/jpeg-static.lib")
if (PkgSkip("ZLIB")==0): LibName("ZLIB", GetThirdpartyDir() + "zlib/lib/zlibstatic.lib")
if (PkgSkip("VRPN")==0): LibName("VRPN", GetThirdpartyDir() + "vrpn/lib/vrpn.lib")
@ -624,7 +628,6 @@ if (COMPILER == "MSVC"):
if (PkgSkip("FFTW")==0): LibName("FFTW", GetThirdpartyDir() + "fftw/lib/rfftw.lib")
if (PkgSkip("FFTW")==0): LibName("FFTW", GetThirdpartyDir() + "fftw/lib/fftw.lib")
if (PkgSkip("ARTOOLKIT")==0):LibName("ARTOOLKIT",GetThirdpartyDir() + "artoolkit/lib/libAR.lib")
if (PkgSkip("FCOLLADA")==0): LibName("FCOLLADA", GetThirdpartyDir() + "fcollada/lib/FCollada.lib")
if (PkgSkip("ASSIMP")==0): PkgDisable("ASSIMP") # Not yet supported
if (PkgSkip("OPENCV")==0): LibName("OPENCV", GetThirdpartyDir() + "opencv/lib/cv.lib")
if (PkgSkip("OPENCV")==0): LibName("OPENCV", GetThirdpartyDir() + "opencv/lib/highgui.lib")
@ -637,6 +640,9 @@ if (COMPILER == "MSVC"):
if (PkgSkip("FFMPEG")==0): LibName("FFMPEG", GetThirdpartyDir() + "ffmpeg/lib/avutil.lib")
if (PkgSkip("SWSCALE")==0): LibName("SWSCALE", GetThirdpartyDir() + "ffmpeg/lib/swscale.lib")
if (PkgSkip("SWRESAMPLE")==0):LibName("SWRESAMPLE",GetThirdpartyDir() + "ffmpeg/lib/swresample.lib")
if (PkgSkip("FCOLLADA")==0):
LibName("FCOLLADA", GetThirdpartyDir() + "fcollada/lib/FCollada.lib")
IncDirectory("FCOLLADA", GetThirdpartyDir() + "fcollada/include/FCollada")
if (PkgSkip("SQUISH")==0):
if GetOptimize() <= 2:
LibName("SQUISH", GetThirdpartyDir() + "squish/lib/squishd.lib")
@ -649,7 +655,11 @@ if (COMPILER == "MSVC"):
LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/" + SDK["PYTHONVERSION"] + "/boost_python-vc100-mt-1_54.lib")
if (GetOptimize() <= 3):
LibName("ROCKET", GetThirdpartyDir() + "rocket/lib/RocketDebugger.lib")
if (PkgSkip("OPENAL")==0): LibName("OPENAL", GetThirdpartyDir() + "openal/lib/OpenAL32.lib")
if (PkgSkip("OPENAL")==0):
LibName("OPENAL", GetThirdpartyDir() + "openal/lib/OpenAL32.lib")
if not os.path.isfile(GetThirdpartyDir() + "openal/bin/OpenAL32.dll"):
# Link OpenAL Soft statically.
DefSymbol("OPENAL", "AL_LIBTYPE_STATIC")
if (PkgSkip("ODE")==0):
LibName("ODE", GetThirdpartyDir() + "ode/lib/ode_single.lib")
DefSymbol("ODE", "dSINGLE", "")
@ -787,7 +797,7 @@ if (COMPILER=="GCC"):
SmartPkgEnable("OPENAL", "openal", ("openal"), "AL/al.h", framework = "OpenAL")
SmartPkgEnable("SQUISH", "", ("squish"), "squish.h")
SmartPkgEnable("TIFF", "libtiff-4", ("tiff"), "tiff.h")
SmartPkgEnable("OPENEXR", "", ("openexr"), "ImfOutputFile.h")
SmartPkgEnable("OPENEXR", "OpenEXR", ("IlmImf", "Imath", "Half", "Iex", "IexMath", "IlmThread"), ("OpenEXR", "OpenEXR/ImfOutputFile.h"))
SmartPkgEnable("VRPN", "", ("vrpn", "quat"), ("vrpn", "quat.h", "vrpn/vrpn_Types.h"))
SmartPkgEnable("BULLET", "bullet", ("BulletSoftBody", "BulletDynamics", "BulletCollision", "LinearMath"), ("bullet", "bullet/btBulletDynamicsCommon.h"))
SmartPkgEnable("VORBIS", "vorbisfile",("vorbisfile", "vorbis", "ogg"), ("ogg/ogg.h", "vorbis/vorbisfile.h"))
@ -2193,7 +2203,7 @@ DTOOL_CONFIG=[
("PHAVE_DIRENT_H", 'UNDEF', '1'),
("PHAVE_SYS_SOUNDCARD_H", 'UNDEF', '1'),
("PHAVE_UCONTEXT_H", 'UNDEF', '1'),
("PHAVE_STDINT_H", 'UNDEF', '1'),
("PHAVE_STDINT_H", '1', '1'),
("HAVE_RTTI", '1', '1'),
("HAVE_X11", 'UNDEF', '1'),
("HAVE_XRANDR", 'UNDEF', '1'),
@ -3835,7 +3845,7 @@ if (not RUNTIME):
#
if (not RUNTIME):
OPTS=['DIR:panda/src/pnmimagetypes', 'DIR:panda/src/pnmimage', 'BUILDING:PANDA', 'PNG', 'ZLIB', 'JPEG', 'TIFF', 'OPENEXR']
OPTS=['DIR:panda/src/pnmimagetypes', 'DIR:panda/src/pnmimage', 'BUILDING:PANDA', 'PNG', 'ZLIB', 'JPEG', 'TIFF', 'OPENEXR', 'EXCEPTIONS']
TargetAdd('p3pnmimagetypes_composite1.obj', opts=OPTS, input='p3pnmimagetypes_composite1.cxx')
TargetAdd('p3pnmimagetypes_composite2.obj', opts=OPTS, input='p3pnmimagetypes_composite2.cxx')
@ -4264,7 +4274,7 @@ if PkgSkip("OPENAL") == 0 and not RUNTIME:
TargetAdd('openal_audio_openal_audio_composite1.obj', opts=OPTS, input='openal_audio_composite1.cxx')
TargetAdd('libp3openal_audio.dll', input='openal_audio_openal_audio_composite1.obj')
TargetAdd('libp3openal_audio.dll', input=COMMON_PANDA_LIBS)
TargetAdd('libp3openal_audio.dll', opts=['MODULE', 'ADVAPI', 'WINUSER', 'WINMM', 'OPENAL'])
TargetAdd('libp3openal_audio.dll', opts=['MODULE', 'ADVAPI', 'WINUSER', 'WINMM', 'WINSHELL', 'WINOLE', 'OPENAL'])
#
# DIRECTORY: panda/src/downloadertools/

View File

@ -2851,6 +2851,17 @@ def GetOrigExt(x):
def SetOrigExt(x, v):
ORIG_EXT[x] = v
def GetExtensionSuffix():
if sys.version_info >= (3, 0):
suffix = sysconfig.get_config_var('EXT_SUFFIX')
if suffix:
return suffix
target = GetTarget()
if target == 'windows':
return '.pyd'
else:
return '.so'
def CalcLocation(fn, ipath):
if fn.startswith("panda3d/") and fn.endswith(".py"):
return OUTPUTDIR + "/" + fn
@ -2872,6 +2883,7 @@ def CalcLocation(fn, ipath):
if (fn.endswith(".xml")): return CxxFindSource(fn, ipath)
if (fn.endswith(".egg")): return OUTPUTDIR+"/models/"+fn
if (fn.endswith(".egg.pz")):return OUTPUTDIR+"/models/"+fn
if (fn.endswith(".pyd")): return OUTPUTDIR+"/panda3d/"+fn[:-4]+GetExtensionSuffix()
if (target == 'windows'):
if (fn.endswith(".def")): return CxxFindSource(fn, ipath)
if (fn.endswith(".rc")): return CxxFindSource(fn, ipath)
@ -2880,7 +2892,6 @@ def CalcLocation(fn, ipath):
if (fn.endswith(".res")): return OUTPUTDIR+"/tmp/"+fn
if (fn.endswith(".tlb")): return OUTPUTDIR+"/tmp/"+fn
if (fn.endswith(".dll")): return OUTPUTDIR+"/bin/"+fn[:-4]+dllext+".dll"
if (fn.endswith(".pyd")): return OUTPUTDIR+"/panda3d/"+fn[:-4]+".pyd"
if (fn.endswith(".ocx")): return OUTPUTDIR+"/plugins/"+fn[:-4]+dllext+".ocx"
if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn[:-4]+dllext+".mll"
if (fn.endswith(".dlo")): return OUTPUTDIR+"/plugins/"+fn[:-4]+dllext+".dlo"
@ -2897,7 +2908,6 @@ def CalcLocation(fn, ipath):
if (fn.endswith(".plist")): return CxxFindSource(fn, ipath)
if (fn.endswith(".obj")): return OUTPUTDIR+"/tmp/"+fn[:-4]+".o"
if (fn.endswith(".dll")): return OUTPUTDIR+"/lib/"+fn[:-4]+".dylib"
if (fn.endswith(".pyd")): return OUTPUTDIR+"/panda3d/"+fn[:-4]+".so"
if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn
if (fn.endswith(".exe")): return OUTPUTDIR+"/bin/"+fn[:-4]
if (fn.endswith(".p3d")): return OUTPUTDIR+"/bin/"+fn[:-4]
@ -2910,7 +2920,6 @@ def CalcLocation(fn, ipath):
# On Android, we build the libraries into built/tmp, then copy them.
if (fn.endswith(".obj")): return OUTPUTDIR+"/tmp/"+fn[:-4]+".o"
if (fn.endswith(".dll")): return OUTPUTDIR+"/tmp/"+fn[:-4]+".so"
if (fn.endswith(".pyd")): return OUTPUTDIR+"/tmp/"+fn[:-4]+".so"
if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn
if (fn.endswith(".plugin")):return OUTPUTDIR+"/plugins/"+fn[:-7]+dllext+".so"
if (fn.endswith(".exe")): return OUTPUTDIR+"/tmp/lib"+fn[:-4]+".so"
@ -2919,7 +2928,6 @@ def CalcLocation(fn, ipath):
else:
if (fn.endswith(".obj")): return OUTPUTDIR+"/tmp/"+fn[:-4]+".o"
if (fn.endswith(".dll")): return OUTPUTDIR+"/lib/"+fn[:-4]+".so"
if (fn.endswith(".pyd")): return OUTPUTDIR+"/panda3d/"+fn[:-4]+".so"
if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn
if (fn.endswith(".plugin")):return OUTPUTDIR+"/plugins/"+fn[:-7]+dllext+".so"
if (fn.endswith(".exe")): return OUTPUTDIR+"/bin/"+fn[:-4]

View File

@ -438,7 +438,7 @@ get_sound_data(MovieAudio *movie, int mode) {
}
int channels = stream->audio_channels();
int samples = (int)(stream->length() * stream->audio_rate());
PN_int16 *data = new PN_int16[samples * channels];
int16_t *data = new int16_t[samples * channels];
stream->read_samples(samples, data);
alBufferData(sd->_sample,
(channels>1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16,

View File

@ -383,8 +383,8 @@ read_stream_data(int bytelen, unsigned char *buffer) {
if (samples > _sd->_stream->ready()) {
samples = _sd->_stream->ready();
}
cursor->read_samples(samples, (PN_int16 *)buffer);
size_t hval = AddHash::add_hash(0, (PN_uint8*)buffer, samples*channels*2);
cursor->read_samples(samples, (int16_t *)buffer);
size_t hval = AddHash::add_hash(0, (uint8_t*)buffer, samples*channels*2);
audio_debug("Streaming " << cursor->get_source()->get_name() << " at " << t << " hash " << hval);
fill += samples;
space -= samples;

View File

@ -20,7 +20,7 @@ INLINE BulletSoftBodyMaterial::
}
/**
* Named constructor intended to be used for asserts with have to return a
* Named constructor intended to be used for asserts which have to return a
* concrete value.
*/
INLINE BulletSoftBodyMaterial BulletSoftBodyMaterial::
@ -44,7 +44,7 @@ get_material() const {
* Getter for the property m_kLST.
*/
INLINE PN_stdfloat BulletSoftBodyMaterial::
getLinearStiffness() const {
get_linear_stiffness() const {
return (PN_stdfloat)_material.m_kLST;
}
@ -53,7 +53,7 @@ getLinearStiffness() const {
* Setter for the property m_kLST.
*/
INLINE void BulletSoftBodyMaterial::
setLinearStiffness(PN_stdfloat value) {
set_linear_stiffness(PN_stdfloat value) {
_material.m_kLST = (btScalar)value;
}
@ -62,7 +62,7 @@ setLinearStiffness(PN_stdfloat value) {
* Getter for the property m_kAST.
*/
INLINE PN_stdfloat BulletSoftBodyMaterial::
getAngularStiffness() const {
get_angular_stiffness() const {
return (PN_stdfloat)_material.m_kAST;
}
@ -71,7 +71,7 @@ getAngularStiffness() const {
* Setter for the property m_kAST.
*/
INLINE void BulletSoftBodyMaterial::
setAngularStiffness(PN_stdfloat value) {
set_angular_stiffness(PN_stdfloat value) {
_material.m_kAST = (btScalar)value;
}
@ -80,7 +80,7 @@ setAngularStiffness(PN_stdfloat value) {
* Getter for the property m_kVST.
*/
INLINE PN_stdfloat BulletSoftBodyMaterial::
getVolumePreservation() const {
get_volume_preservation() const {
return (PN_stdfloat)_material.m_kVST;
}
@ -89,7 +89,7 @@ getVolumePreservation() const {
* Setter for the property m_kVST.
*/
INLINE void BulletSoftBodyMaterial::
setVolumePreservation(PN_stdfloat value) {
set_volume_preservation(PN_stdfloat value) {
_material.m_kVST = (btScalar)value;
}

View File

@ -27,13 +27,17 @@ PUBLISHED:
INLINE ~BulletSoftBodyMaterial();
INLINE static BulletSoftBodyMaterial empty();
INLINE void setLinearStiffness(PN_stdfloat value);
INLINE void setAngularStiffness(PN_stdfloat value);
INLINE void setVolumePreservation(PN_stdfloat value);
INLINE PN_stdfloat getLinearStiffness() const;
INLINE PN_stdfloat getAngularStiffness() const;
INLINE PN_stdfloat getVolumePreservation() const;
INLINE void set_linear_stiffness(PN_stdfloat value);
INLINE PN_stdfloat get_linear_stiffness() const;
MAKE_PROPERTY(linear_stiffness, get_linear_stiffness, set_linear_stiffness);
INLINE void set_angular_stiffness(PN_stdfloat value);
INLINE PN_stdfloat get_angular_stiffness() const;
MAKE_PROPERTY(angular_stiffness, get_angular_stiffness, set_angular_stiffness);
INLINE void set_volume_preservation(PN_stdfloat value);
INLINE PN_stdfloat get_volume_preservation() const;
MAKE_PROPERTY(volume_preservation, get_volume_preservation, set_volume_preservation);
public:
BulletSoftBodyMaterial(btSoftBody::Material &material);

View File

@ -44,6 +44,8 @@ PUBLISHED:
AnimGroup *get_child(int n) const;
MAKE_SEQ(get_children, get_num_children, get_child);
MAKE_SEQ_PROPERTY(children, get_num_children, get_child);
AnimGroup *get_child_named(const string &name) const;
AnimGroup *find_child(const string &name) const;
void sort_descendants();

View File

@ -113,6 +113,12 @@ PUBLISHED:
INLINE PartBundleNode *get_node(int n) const;
MAKE_SEQ(get_nodes, get_num_nodes, get_node);
MAKE_PROPERTY(blend_type, get_blend_type, set_blend_type);
MAKE_PROPERTY(anim_blend_flag, get_anim_blend_flag, set_anim_blend_flag);
MAKE_PROPERTY(frame_blend_flag, get_frame_blend_flag, set_frame_blend_flag);
MAKE_PROPERTY(root_xform, get_root_xform, set_root_xform);
MAKE_SEQ_PROPERTY(nodes, get_num_nodes, get_node);
void clear_control_effects();
INLINE void set_control_effect(AnimControl *control, PN_stdfloat effect);
INLINE PN_stdfloat get_control_effect(AnimControl *control) const;

View File

@ -38,6 +38,8 @@ PUBLISHED:
INLINE PartBundle *get_bundle();
INLINE void set_bundle(PartBundle *bundle);
MAKE_PROPERTY(bundle, get_bundle, set_bundle);
private:
PT(PartBundle) _bundle;
};

View File

@ -54,6 +54,9 @@ PUBLISHED:
INLINE PartBundleHandle *get_bundle_handle(int n) const;
MAKE_SEQ(get_bundle_handles, get_num_bundles, get_bundle_handle);
MAKE_SEQ_PROPERTY(bundles, get_num_bundles, get_bundle);
MAKE_SEQ_PROPERTY(bundle_handles, get_num_bundles, get_bundle_handle);
protected:
void add_bundle(PartBundle *bundle);
void add_bundle_handle(PartBundleHandle *handle);

View File

@ -70,6 +70,7 @@ PUBLISHED:
int get_num_children() const;
PartGroup *get_child(int n) const;
MAKE_SEQ(get_children, get_num_children, get_child);
MAKE_SEQ_PROPERTY(children, get_num_children, get_child);
PartGroup *get_child_named(const string &name) const;
PartGroup *find_child(const string &name) const;

View File

@ -40,7 +40,6 @@ public:
} TriangleIndices;
PUBLISHED:
INLINE CollisionFloorMesh();
INLINE void add_vertex(const LPoint3 &vert);
@ -55,6 +54,10 @@ PUBLISHED:
virtual LPoint3 get_collision_origin() const;
PUBLISHED:
MAKE_SEQ_PROPERTY(vertices, get_num_vertices, get_vertex);
MAKE_SEQ_PROPERTY(triangles, get_num_triangles, get_triangle);
public:
CollisionFloorMesh(const CollisionFloorMesh &copy);
virtual CollisionSolid *make_copy();

View File

@ -60,6 +60,10 @@ PUBLISHED:
INLINE string get_out_pattern(int n) const;
MAKE_SEQ(get_out_patterns, get_num_out_patterns, get_out_pattern);
MAKE_SEQ_PROPERTY(in_patterns, get_num_in_patterns, get_in_pattern);
MAKE_SEQ_PROPERTY(again_patterns, get_num_again_patterns, get_out_pattern);
MAKE_SEQ_PROPERTY(out_patterns, get_num_out_patterns, get_out_pattern);
void clear();
void flush();

View File

@ -40,6 +40,7 @@ PUBLISHED:
int get_num_entries() const;
CollisionEntry *get_entry(int n) const;
MAKE_SEQ(get_entries, get_num_entries, get_entry);
MAKE_SEQ_PROPERTY(entries, get_num_entries, get_entry);
void output(ostream &out) const;
void write(ostream &out, int indent_level = 0) const;

View File

@ -68,6 +68,7 @@ PUBLISHED:
INLINE void set_solid(int n, CollisionSolid *solid);
INLINE void remove_solid(int n);
INLINE int add_solid(const CollisionSolid *solid);
MAKE_SEQ_PROPERTY(solids, get_num_solids, get_solid, set_solid, remove_solid);
INLINE int get_collider_sort() const;
INLINE void set_collider_sort(int sort);

View File

@ -60,6 +60,7 @@ PUBLISHED:
bool is_concave() const;
PUBLISHED:
MAKE_SEQ_PROPERTY(points, get_num_points, get_point);
MAKE_PROPERTY(valid, is_valid);
MAKE_PROPERTY(concave, is_concave);

View File

@ -60,6 +60,7 @@ PUBLISHED:
MAKE_SEQ(get_colliders, get_num_colliders, get_collider);
CollisionHandler *get_handler(const NodePath &collider) const;
void clear_colliders();
MAKE_SEQ_PROPERTY(colliders, get_num_colliders, get_collider);
void traverse(const NodePath &root);

Some files were not shown because too many files have changed in this diff Show More