EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PyRep.cpp
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur
24  Rewrite: Allan
25 */
26 
27 #include "eve-common.h"
28 
29 #include "marshal/EVEMarshal.h"
30 #include "marshal/EVEUnmarshal.h"
33 #include "python/PyDumpVisitor.h"
34 #include "python/PyVisitor.h"
35 #include "python/PyRep.h"
36 #include "utils/EVEUtils.h"
37 
39 const char* const s_mTypeString[] =
40 {
41  "Min",
42  "Integer", //1
43  "Long", //2
44  "Real", //3
45  "Boolean", //4
46  "Buffer", //5
47  "String", //6
48  "WString", //7
49  "Token", //8
50  "Tuple", //9
51  "List", //10
52  "Dict", //11
53  "None", //12
54  "SubStruct", //13
55  "SubStream", //14
56  "ChecksumedStream", //15
57  "Object", //16
58  "ObjectEx", //17
59  "PackedRow", //18
60  "Invalid Type" //19
61 };
62 
70 /************************************************************************/
71 /* PyRep base Class */
72 /************************************************************************/
73 PyRep::PyRep(PyType t) : RefObject(1), mType( t ) { }
74 PyRep::PyRep(const PyRep& oth) : RefObject(1/*oth.GetCount()*/), mType(oth.mType) {}
75 
76 const char* PyRep::TypeString() const
77 {
78  if ((mType > PyTypeMin) and (mType < PyTypeError))
79  return s_mTypeString[ mType ];
80 
81  return s_mTypeString[ PyTypeError ];
82 }
83 
84 void PyRep::Dump( FILE* into, const char* pfx ) const
85 {
86  PyFileDumpVisitor dumper( into, pfx );
87  visit( dumper );
88 }
89 
90 void PyRep::Dump( LogType type, const char* pfx ) const
91 {
92  PyLogDumpVisitor dumper( type, type, pfx );
93  visit( dumper );
94 }
95 
97 {
98  sLog.Error( "Hash", "Unhashable type: '%s'", TypeString() );
99  return -1;
100 }
101 
102 
103 std::string PyRep::StringContent(PyRep* pRep)
104 {
105  if (pRep == nullptr)
106  return "";
107  else if (pRep->IsString())
108  return pRep->AsString()->content();
109  else if (pRep->IsWString())
110  return pRep->AsWString()->content();
111  else if (pRep->IsNone())
112  return "";
113 
114  _log(COMMON__ERROR, "PyRep::StringContent() - Expected PyString or PyWString but got %s.", pRep->TypeString());
115  return "";
116 }
117 
119 {
120  if (pRep == nullptr)
121  return 0;
122  else if (pRep->IsInt())
123  return pRep->AsInt()->value();
124  else if (pRep->IsLong())
125  return pRep->AsLong()->value();
126  else if (pRep->IsFloat())
127  return pRep->AsFloat()->value();
128  else if (pRep->IsBool())
129  return pRep->AsBool()->value();
130 
131  return 0;
132 }
133 
135  if (pRep == nullptr)
136  return 0;
137  else if (pRep->IsInt())
138  return pRep->AsInt()->value();
139  else if (pRep->IsLong())
140  return pRep->AsLong()->value();
141  else if (pRep->IsFloat())
142  return pRep->AsFloat()->value();
143  else if (pRep->IsBool())
144  return pRep->AsBool()->value();
145 
146  return 0;
147 }
148 
149 
150 /************************************************************************/
151 /* PyRep Integer Class */
152 /************************************************************************/
153 PyInt::PyInt( const int32 i ) : PyRep( PyRep::PyTypeInt ), mValue( i ) {}
154 PyInt::PyInt( const PyInt& oth ) : PyRep( PyRep::PyTypeInt ), mValue( oth.value() ) {}
155 
157 {
158  return new PyInt( *this );
159 }
160 
161 bool PyInt::visit( PyVisitor& v ) const
162 {
163  return v.VisitInteger( this );
164 }
165 
167 {
168  /* XXX If this is changed, you also need to change the way
169  * Python's long, float and complex types are hashed. */
170  int32 x = mValue;
171  if (x == -1 )
172  x = -2;
173  return x;
174 }
175 
176 /************************************************************************/
177 /* PyRep Long Class */
178 /************************************************************************/
179 PyLong::PyLong( const int64 i ) : PyRep( PyRep::PyTypeLong ), mValue( i ) {}
180 PyLong::PyLong( const PyLong& oth ) : PyRep( PyRep::PyTypeLong ), mValue( oth.value() ) {}
181 
183 {
184  return new PyLong( *this );
185 }
186 
187 bool PyLong::visit( PyVisitor& v ) const
188 {
189  return v.VisitLong( this );
190 }
191 
193 {
194 #define PyLong_SHIFT 15
195 #define PyLong_BASE (1 << PyLong_SHIFT)
196 #define PyLong_MASK ((int)(PyLong_BASE - 1))
197 
198 #define LONG_BIT_PyLong_SHIFT (8*sizeof(long) - PyLong_SHIFT)
199 
200  long x=0;
201  int i=8, sign=1;
202 
203  /* This is designed so that Python ints and longs with the
204  same value hash to the same value, otherwise comparisons
205  of mapping keys will turn out weird */
206  if (i < 0 ) {
207  sign = -1;
208  i = -(i);
209  }
210  /* The following loop produces a C long x such that (unsigned long)x
211  is congruent to the absolute value of v modulo ULONG_MAX. The
212  resulting x is nonzero if and only if v is. */
213  while( --i >= 0 ) {
214  /* Force a native long #-bits (32 or 64) circular shift */
215  x = ((x << PyLong_SHIFT) & ~PyLong_MASK) | ((x >> LONG_BIT_PyLong_SHIFT) & PyLong_MASK);
216  x += ((uint8*)&mValue)[i];// v->ob_digit[i];
217  /* If the addition above overflowed (thinking of x as
218  unsigned), we compensate by incrementing. This preserves
219  the value modulo ULONG_MAX. */
220  if ((unsigned long)x < ((uint8*)&mValue)[i] )//v->ob_digit[i])
221  x++;
222  }
223  x = x * sign;
224  if (x == -1 )
225  x = -2;
226  return x;
227 
228 #undef PyLong_SHIFT
229 #undef PyLong_BASE
230 #undef PyLong_MASK
231 
232 #undef LONG_BIT_PyLong_SHIFT
233 }
234 
235 /************************************************************************/
236 /* PyRep Real/float/double Class */
237 /************************************************************************/
238 PyFloat::PyFloat( const double& i ) : PyRep( PyRep::PyTypeFloat ), mValue( i ) { }
239 PyFloat::PyFloat( const PyFloat& oth ) : PyRep( PyRep::PyTypeFloat ), mValue( oth.value() ) { }
240 
242 {
243  return new PyFloat( *this );
244 }
245 
246 bool PyFloat::visit( PyVisitor& v ) const
247 {
248  return v.VisitReal( this );
249 }
250 
251 // maximum int32 value
252 #ifndef INT32_MAX
253 # define INT32_MAX 2147483647L
254 #endif /* !INT32_MAX */
255 
257 {
258 #define Py_IS_INFINITY( X ) \
259  ( !finite( X ) && !isnan( X ) )
260 
261  double v = mValue;
262  double intpart=0.0, fractpart=0.0;
263  int expo=0;
264  long hipart=0, x=0; /* x is the final hash value */
265  /* This is designed so that Python numbers of different types
266  * that compare equal hash to the same value; otherwise comparisons
267  * of mapping keys will turn out weird.
268  */
269 
270  fractpart = modf(v, &intpart);
271  if (fractpart == 0.0) {
272  /* This must return the same hash as an equal int or long. */
273  if ((intpart > INT32_MAX) or (-intpart > INT32_MAX)) {
274  /* Convert to long and use its hash. */
275  if (Py_IS_INFINITY(intpart))
276  /* can't convert to long int -- arbitrary */
277  v = v < 0 ? -271828.0 : 314159.0;
278  //plong = PyLong_FromDouble(v);
279 
280  PyRep *plong = new PyLong( (int64)v ); // this is a hack
281  if (plong == nullptr)
282  return -1;
283  x = plong->hash();
284  PyDecRef( plong );
285  return x;
286  }
287  /* Fits in a C long == a Python int, so is its own hash. */
288  x = (long)intpart;
289  if (x == -1)
290  x = -2;
291  return x;
292  }
293  /* The fractional part is non-zero, so we don't have to worry about
294  * making this match the hash of some other type.
295  * Use frexp to get at the bits in the double.
296  * Since the VAX D double format has 56 mantissa bits, which is the
297  * most of any double format in use, each of these parts may have as
298  * many as (but no more than) 56 significant bits.
299  * So, assuming sizeof(long) >= 4, each part can be broken into two
300  * longs; frexp and multiplication are used to do that.
301  * Also, since the Cray double format has 15 exponent bits, which is
302  * the most of any double format in use, shifting the exponent field
303  * left by 15 won't overflow a long (again assuming sizeof(long) >= 4).
304  */
305  v = frexp(v, &expo);
306  v *= 2147483648.0; /* 2**31 */
307  hipart = (long)v; /* take the top 32 bits */
308  v = (v - (double)hipart) * 2147483648.0; /* get the next 32 bits */
309  x = hipart + (long)v + (expo << 15);
310  if (x == -1)
311  x = -2;
312  return x;
313 
314 #undef Py_IS_INFINITY
315 }
316 
317 /************************************************************************/
318 /* PyRep Boolean Class */
319 /************************************************************************/
320 PyBool::PyBool( bool i ) : PyRep( PyRep::PyTypeBool ), mValue( i ) { }
321 PyBool::PyBool( const PyBool& oth ) : PyRep( PyRep::PyTypeBool ), mValue( oth.value() ) { }
322 
324 {
325  return new PyBool( *this );
326 }
327 
328 bool PyBool::visit( PyVisitor& v ) const
329 {
330  return v.VisitBoolean( this );
331 }
332 
333 /************************************************************************/
334 /* PyRep None Class */
335 /************************************************************************/
336 PyNone::PyNone() : PyRep( PyRep::PyTypeNone ) {}
337 PyNone::PyNone( const PyNone& oth ) : PyRep( PyRep::PyTypeNone ) {}
338 
340 {
341  return new PyNone( *this );
342 }
343 
344 bool PyNone::visit( PyVisitor& v ) const
345 {
346  return v.VisitNone( this );
347 }
348 
350 {
351  /* damn hack... bleh.. but its done like this... in python a PyNone is a static singleton....*/
352  int32* hash = (int32*)this;
353  return *((int32*)&hash);
354 }
355 
356 /************************************************************************/
357 /* PyRep Buffer Class */
358 /************************************************************************/
359 PyBuffer::PyBuffer( size_t len, const uint8& value )
360 : PyRep( PyRep::PyTypeBuffer ), mValue( new Buffer( len, value ) ), mHashCache( -1 ) {}
361 PyBuffer::PyBuffer( const Buffer& buffer )
362 : PyRep( PyRep::PyTypeBuffer ), mValue( new Buffer( buffer ) ), mHashCache( -1 ) {}
363 
365 : PyRep( PyRep::PyTypeBuffer ), mValue( *buffer ), mHashCache( -1 ) { *buffer = nullptr; }
367 : PyRep( PyRep::PyTypeBuffer ), mValue( new Buffer( str.content().begin(), str.content().end() ) ), mHashCache( -1 ) {}
368 PyBuffer::PyBuffer( const PyBuffer& buffer )
369 : PyRep( PyRep::PyTypeBuffer ), mValue( new Buffer( buffer.content() ) ), mHashCache( buffer.mHashCache ) {}
370 
372 {
373  delete mValue;
374 }
375 
377 {
378  return new PyBuffer( *this );
379 }
380 
381 bool PyBuffer::visit( PyVisitor& v ) const
382 {
383  return v.VisitBuffer( this );
384 }
385 
387 {
388  if (mHashCache != -1 )
389  return mHashCache;
390 
391  int32 len=0, x=0;
392  unsigned char* p(nullptr);
393 
394  /* XXX potential bugs here, a readonly buffer does not imply that the
395  * underlying memory is immutable. b_readonly is a necessary but not
396  * sufficient condition for a buffer to be hashable. Perhaps it would
397  * be better to only allow hashing if the underlying object is known to
398  * be immutable (e.g. PyString_Check() is true). Another idea would
399  * be to call tp_hash on the underlying object and see if it raises
400  * an error. */
401  //if ( !self->b_readonly )
402  //{
403  // PyErr_SetString(PyExc_TypeError,
404  // "writable buffers are not hashable");
405  // return -1;
406  //}
407 
408  //if (!get_buf(self, &ptr, &size, ANY_BUFFER))
409  // return -1;
410  p = (unsigned char *) &content()[0];
411  len = (int32)content().size();
412  x = *p << 7;
413  while( --len >= 0 )
414  x = (1000003*x) ^ *p++;
415  x ^= content().size();
416  if (x == -1)
417  x = -2;
418  mHashCache = x;
419  return x;
420 }
421 
422 size_t PyBuffer::size() const
423 {
424  return content().size();
425 }
426 
427 /************************************************************************/
428 /* PyString */
429 /************************************************************************/
430 PyString::PyString( const char* str )
431 : PyRep( PyRep::PyTypeString ), mValue( str ), mHashCache( -1 ) {}
432 PyString::PyString( const char* str, size_t len )
433 : PyRep( PyRep::PyTypeString ), mValue( str, len ), mHashCache( -1 ) {}
434 PyString::PyString( const std::string& str )
435 : PyRep( PyRep::PyTypeString ), mValue( str ), mHashCache( -1 ) {}
436 
438 : PyRep( PyRep::PyTypeString ), mValue( (const char *) &buf.content()[0], buf.content().size() ), mHashCache( -1 ) {}
440 : PyRep( PyRep::PyTypeString ), mValue( token.content() ), mHashCache( -1 ) {}
442 : PyRep( PyRep::PyTypeString ), mValue( oth.mValue ), mHashCache( oth.mHashCache ) {}
443 
445 {
446  // how do we determine whether to `delete` a const char* or just clear a `std::string&`?
447  // either way, valgrind shows this leaking on most calls, probably after Clone().
448 }
449 
451 {
452  return new PyString( *this );
453 }
454 
455 bool PyString::visit( PyVisitor& v ) const
456 {
457  return v.VisitString( this );
458 }
459 
461 {
462  if (mHashCache != -1 )
463  return mHashCache;
464 
465  if (mValue.length() > 0)
466  mHashCache = std::hash<std::string>{} (mValue);
467  else
468  mHashCache = 0;
469 
470  return mHashCache;
471 }
472 
473 /************************************************************************/
474 /* PyWString */
475 /************************************************************************/
476 PyWString::PyWString( const char* str, size_t len )
477 : PyRep( PyRep::PyTypeWString ), mValue( str, len ), mHashCache( -1 ) {}
478 PyWString::PyWString( const std::string& str )
479 : PyRep( PyRep::PyTypeWString ), mValue( str ), mHashCache( -1 ) {}
480 
482 : PyRep( PyRep::PyTypeWString ), mValue( str.content() ), mHashCache( -1 ) {}
484 : PyRep( PyRep::PyTypeWString ), mValue( oth.mValue ), mHashCache( oth.mHashCache ) {}
485 
487 {
488  return new PyWString( *this );
489 }
490 
491 bool PyWString::visit( PyVisitor& v ) const
492 {
493  return v.VisitWString( this );
494 }
495 
496 size_t PyWString::size() const
497 {
498  return utf8::distance( content().begin(), content().end() );
499 }
500 
502 {
503  if (mHashCache != -1 )
504  return mHashCache;
505 
506  if (mValue.length() > 0)
507  mHashCache = std::hash<std::string>{} (mValue);
508  else
509  mHashCache = 0;
510 
511  return mHashCache;
512 }
513 
514 /************************************************************************/
515 /* PyToken */
516 /************************************************************************/
517 PyToken::PyToken( const char* token ) : PyRep( PyRep::PyTypeToken ), mValue( token ) {}
518 PyToken::PyToken( const char* token, size_t len ) : PyRep( PyRep::PyTypeToken ), mValue( token, len ) {}
519 PyToken::PyToken( const std::string& token ) : PyRep( PyRep::PyTypeToken ), mValue( token ) {}
520 
521 PyToken::PyToken( const PyString& token ) : PyRep( PyRep::PyTypeToken ), mValue( token.content() ) {}
522 PyToken::PyToken( const PyToken& oth ) : PyRep( PyRep::PyTypeToken ), mValue( oth.content() ) {}
523 
525 {
526  return new PyToken( *this );
527 }
528 
529 bool PyToken::visit( PyVisitor& v ) const
530 {
531  return v.VisitToken( this );
532 }
533 
534 /************************************************************************/
535 /* PyRep Tuple Class */
536 /************************************************************************/
537 PyTuple::PyTuple( size_t item_count ) : PyRep( PyRep::PyTypeTuple ), items( item_count, nullptr ) {}
538 PyTuple::PyTuple( const PyTuple& oth ) : PyRep( PyRep::PyTypeTuple ), items(oth.items)
539 {
540 }
541 
543 {
544  //for (auto cur : items)
545  // PySafeDecRef(cur);
546 }
547 
549 {
550  return new PyTuple( *this );
551 }
552 
553 bool PyTuple::visit( PyVisitor& v ) const
554 {
555  return v.VisitTuple( this );
556 }
557 
559 {
560  iterator cur = items.begin(), end = items.end();
561  for (; cur != end; ++cur)
562  PySafeDecRef( *cur );
563 
564  items.clear();
565 }
566 
568 {
569  clear();
570  items.resize( oth.size() );
571  iterator cur = items.begin(), end = items.end();
572  const_iterator cur_oth = oth.begin(), oth_end = oth.end();
573  for (; cur != end && cur_oth != oth_end; ++cur, ++cur_oth)
574  {
575  if (*cur_oth == nullptr )
576  *cur = nullptr;
577  else
578  *cur = (*cur_oth)->Clone();
579  }
580 
581  return *this;
582 }
583 
585 {
586  long x=0, y=0;
587  int32 len = (int32)items.size();
588  long index = 0;
589  long mult = 1000003L;
590  x = 0x345678L;
591  while (--len >= 0) {
592  y = items[index++]->hash();
593  if (y == -1)
594  return -1;
595  x = (x ^ y) * mult;
596  /* the cast might truncate len; that doesn't change hash stability */
597  mult += (long)(82520L + len + len);
598  }
599  x += 97531L;
600  if (x == -1)
601  x = -2;
602  return (uint32)x;
603 }
604 
605 /************************************************************************/
606 /* PyRep List Class */
607 /************************************************************************/
608 PyList::PyList(size_t item_count) : PyRep(PyRep::PyTypeList), items(item_count, nullptr) { }
609 PyList::PyList(const PyList& oth) : PyRep(PyRep::PyTypeList), items(oth.items) { }
610 
612 {
613  //for (auto cur : items)
614  // PySafeDecRef(cur);
615 }
616 
618 {
619  return new PyList( *this );
620 }
621 
622 bool PyList::visit( PyVisitor& v ) const
623 {
624  return v.VisitList( this );
625 }
626 
628 {
629  iterator cur = items.begin(), end = items.end();
630  for (; cur != end; ++cur)
631  PySafeDecRef( *cur );
632 
633  items.clear();
634 }
635 
636 // copy assignment
638 {
639  clear();
640  items.resize( oth.size() );
641  iterator cur = items.begin(), end = items.end();
642  const_iterator cur_oth = oth.begin(), oth_end = oth.end();
643  for (; cur != end && cur_oth != oth_end; ++cur, ++cur_oth)
644  {
645  if (*cur_oth == nullptr )
646  *cur = nullptr;
647  else
648  *cur = (*cur_oth)->Clone();
649  }
650 
651  return *this;
652 }
653 
654 /************************************************************************/
655 /* PyRep Dict Class */
656 /************************************************************************/
657 PyDict::PyDict() : PyRep( PyRep::PyTypeDict ), items() { }
658 PyDict::PyDict( const PyDict& oth ) : PyRep( PyRep::PyTypeDict ), items(oth.items) { }
659 
661 {
662  /*
663  for (auto cur : items) {
664  PyDecRef(cur.first);
665  PySafeDecRef(cur.second);
666  }
667  */
668 }
669 
671 {
672  return new PyDict( *this );
673 }
674 
675 bool PyDict::visit( PyVisitor& v ) const
676 {
677  return v.VisitDict( this );
678 }
679 
681 {
682  iterator cur = items.begin();
683  for (; cur != items.end(); ++cur) {
684  PyDecRef( cur->first );
685  PySafeDecRef( cur->second );
686  }
687 
688  items.clear();
689 }
690 
692 {
693  assert( key != nullptr );
694 
695  const_iterator res = items.find( key );
696  if (res == items.end() )
697  return nullptr;
698 
699  return res->second;
700 }
701 
702 PyRep* PyDict::GetItemString( const char* key ) const
703 {
704  assert( key != nullptr );
705 
706  PyString* str = new PyString( key );
707  PyRep* res = GetItem( str );
708  PyDecRef( str );
709 
710  return res;
711 }
712 
713 void PyDict::SetItem( PyRep* key, PyRep* value )
714 {
715  if ( key == nullptr )
716  return;
717 
718  /* note: add check if the key object is hashable
719  * if not ( it will return -1 ) return false;
720  */
721  if (key->hash() == -1)
722  return;
723 
724  /* check if we need to replace a dictionary entry */
725  iterator itr = items.find( key );
726  if (itr == items.end()) {
727  // Keep both key & value (make_pair makes copy of args passed)
728  items.insert( std::make_pair( key, value ) );
729  } else {
730  // We found 'key' in current dict, so use itr->first and decRef 'key'.
731  // is this right?
732  PyDecRef( key );
733  // Replace itr->second with new value.
734  PySafeDecRef( itr->second );
735  if (value == nullptr)
736  itr->second = PyStatic.NewNone();
737  else
738  itr->second = value;
739  }
740 }
741 
742 // copy assignment
744 {
745  clear();
746  const_iterator cur = oth.begin(), end = oth.end();
747  for (; cur != end; ++cur) {
748  if (cur->second == nullptr )
749  SetItem( cur->first->Clone(), nullptr );
750  else
751  SetItem( cur->first->Clone(), cur->second->Clone() );
752  }
753 
754  return *this;
755 }
756 
757 /************************************************************************/
758 /* PyRep Object Class */
759 /************************************************************************/
761 : PyRep(PyRep::PyTypeObject), mType(type), mArguments(args) { }
762 PyObject::PyObject(const char* type, PyRep* args )
763 : PyRep(PyRep::PyTypeObject), mType(new PyString(type)), mArguments(args) { }
765 : PyRep(PyRep::PyTypeObject), mType(new PyString(*oth.type())), mArguments(oth.arguments()) { }
766 
768 {
769  PyDecRef( mType );
770  PyDecRef( mArguments );
771 }
772 
774 {
775  return new PyObject( *this );
776 }
777 
778 bool PyObject::visit( PyVisitor& v ) const
779 {
780  return v.VisitObject( this );
781 }
782 
783 /************************************************************************/
784 /* PyObjectEx */
785 /************************************************************************/
786 PyObjectEx::PyObjectEx(bool is_type_2, PyRep* header) : PyRep(PyRep::PyTypeObjectEx),
787  mHeader(header), mIsType2(is_type_2), mList(new PyList()), mDict(new PyDict()) { }
788 PyObjectEx::PyObjectEx( const PyObjectEx& oth ) : PyRep( PyRep::PyTypeObjectEx ),
789  mHeader(oth.header()->Clone()), mIsType2(oth.isType2()), mList(new PyList()), mDict(new PyDict()) { }
790 
792 {
794 
795  PyDecRef( mList );
796  PyDecRef( mDict );
797 }
798 
800 {
801  return new PyObjectEx( *this );
802 }
803 
804 bool PyObjectEx::visit( PyVisitor& v ) const
805 {
806  return v.VisitObjectEx( this );
807 }
808 
810 {
811  list() = oth.list();
812  dict() = oth.dict();
813 
814  return *this;
815 }
816 
817 /************************************************************************/
818 /* PyObjectEx_Type1 */
819 /************************************************************************/
821 : PyObjectEx(false, _CreateHeader(type, args, enclosed)) { }
823 : PyObjectEx(false, _CreateHeader(args1, args2, enclosed)) { }
824 PyObjectEx_Type1::PyObjectEx_Type1(PyToken* type, PyTuple* args, PyDict* keywords, bool enclosed )
825 : PyObjectEx(false, _CreateHeader(type, args, keywords, enclosed)) { }
826 PyObjectEx_Type1::PyObjectEx_Type1(PyToken* type, PyTuple* args, PyList* keywords, bool enclosed )
827 : PyObjectEx(false, _CreateHeader(type, args, keywords, enclosed)) { }
828 
830 {
831  assert( header() != nullptr );
832  return header()->AsTuple()->GetItem( 0 )->AsToken();
833 }
834 
836 {
837  assert( header() != nullptr );
838  return header()->AsTuple()->GetItem( 1 )->AsTuple();
839 }
840 
842 {
843  // This one is slightly more complicated since keywords are optional.
844  assert( header() != nullptr );
845  PyTuple* t = header()->AsTuple();
846 
847  if (t->size() < 3 )
848  t->items.push_back( new PyDict );
849 
850  return t->GetItem( 2 )->AsDict();
851 }
852 
853 PyRep* PyObjectEx_Type1::FindKeyword( const char* keyword ) const
854 {
855  PyDict* kw = GetKeywords();
856 
857  PyDict::const_iterator cur = kw->begin();
858  for (; cur != kw->end(); ++cur) {
859  if (cur->first->IsString() )
860  if (cur->first->AsString()->content() == keyword )
861  return cur->second;
862  }
863 
864  return nullptr;
865 }
866 
867 PyTuple* PyObjectEx_Type1::_CreateHeader( PyToken* type, PyTuple* args, bool enclosed /*false*/ )
868 {
869  if (args == nullptr )
870  args = new PyTuple( 0 );
871 
872  PyTuple* body = new PyTuple( 2 );
873  if (enclosed) {
874  PyTuple* body1 = new PyTuple( 1 );
875  body1->SetItem( 0, type );
876 
877  body->SetItem( 0, body1 );
878  body->SetItem( 1, args );
879  } else {
880  body->SetItem( 0, type );
881  body->SetItem( 1, args );
882  }
883 
884  return body;
885 }
886 
887 PyTuple* PyObjectEx_Type1::_CreateHeader( PyObjectEx_Type1* args1, PyTuple* args2, bool enclosed /*false*/ )
888 {
889  if (args2 == nullptr )
890  args2 = new PyTuple( 0 );
891 
892  PyTuple* body = new PyTuple( 2 );
893  if (enclosed) {
894  PyTuple* body1 = new PyTuple( 1 );
895  body1->SetItem( 0, args1 );
896 
897  body->SetItem( 0, body1 );
898  body->SetItem( 1, args2 );
899  } else {
900  body->SetItem( 0, args1 );
901  body->SetItem( 1, args2 );
902  }
903 
904  return body;
905 }
906 
907 PyTuple* PyObjectEx_Type1::_CreateHeader( PyToken* type, PyTuple* args, PyDict* keywords, bool enclosed /*false*/ )
908 {
909  if (args == nullptr )
910  args = new PyTuple( 0 );
911 
912  PyTuple* body = new PyTuple( keywords == nullptr ? 2 : 3 );
913  body->SetItem( 0, type );
914  body->SetItem( 1, args );
915  if (body->size() > 2 )
916  body->SetItem( 2, keywords );
917  if (enclosed)
918  codelog(COMMON__WARNING, "This constructor is used. please finish code.");
919 
920  return body;
921 }
922 
923 PyTuple* PyObjectEx_Type1::_CreateHeader( PyToken* type, PyTuple* args, PyList* keywords, bool enclosed /*false*/ )
924 {
925  if (args == nullptr )
926  args = new PyTuple( 0 );
927 
928  PyTuple* body = new PyTuple( keywords == nullptr ? 2 : 3 );
929  body->SetItem( 0, type );
930  body->SetItem( 1, args );
931  if (body->size() > 2 )
932  body->SetItem( 2, keywords );
933  if (enclosed)
934  codelog(COMMON__WARNING, "This constructor is used. please finish code.");
935 
936  return body;
937 }
938 
939 /************************************************************************/
940 /* PyObjectEx_Type2 */
941 /************************************************************************/
942 PyObjectEx_Type2::PyObjectEx_Type2( PyTuple* args, PyDict* keywords, bool enclosed /*false*/ )
943 : PyObjectEx( true, _CreateHeader( args, keywords, enclosed)) { }
944 PyObjectEx_Type2::PyObjectEx_Type2( PyToken* args, PyDict* keywords, bool enclosed /*false*/ )
945 : PyObjectEx( true, _CreateHeader( args, keywords, enclosed)) { }
946 
948 {
949  assert( header() != nullptr );
950  return header()->AsTuple()->GetItem( 0 )->AsTuple();
951 }
952 
954 {
955  assert( header() != nullptr );
956  return header()->AsTuple()->GetItem( 1 )->AsDict();
957 }
958 
959 PyRep* PyObjectEx_Type2::FindKeyword( const char* keyword ) const
960 {
961  PyDict* kw = GetKeywords();
962  PyDict::const_iterator cur = kw->begin();
963  for (; cur != kw->end(); ++cur)
964  if ( cur->first->IsString() )
965  if ( cur->first->AsString()->content() == keyword )
966  return cur->second;
967 
968  return nullptr;
969 }
970 
971 PyTuple* PyObjectEx_Type2::_CreateHeader( PyTuple* args, PyDict* keywords, bool enclosed /*false*/ )
972 {
973  assert( args != nullptr );
974  if (keywords == nullptr )
975  keywords = new PyDict();
976 
977  PyTuple* body = new PyTuple( 2 );
978  body->SetItem( 0, args );
979  body->SetItem( 1, keywords );
980  /*
981  if (enclosed) {
982  PyTuple* head = new PyTuple( 1 );
983  head->SetItem( 0, body );
984  } */
985 
986  return body; // head;
987 }
988 
989 PyTuple* PyObjectEx_Type2::_CreateHeader( PyToken* args, PyDict* keywords, bool enclosed /*false*/ )
990 {
991  assert( args != nullptr );
992  if (keywords == nullptr )
993  keywords = new PyDict();
994 
995  PyTuple* body = new PyTuple( 2 );
996  body->SetItem( 0, args );
997  body->SetItem( 1, keywords );
998 
999  if (enclosed) {
1000  PyTuple* head = new PyTuple( 1 );
1001  head->SetItem( 0, body );
1002  }
1003 
1004  return body; // head;
1005 }
1006 
1007 /************************************************************************/
1008 /* PyPackedRow */
1009 /************************************************************************/
1011 : PyRep(PyRep::PyTypePackedRow), mHeader(header), mFields(new PyList(header->ColumnCount()) ) { }
1013 : PyRep(PyRep::PyTypePackedRow), mHeader(oth.header()), mFields(new PyList(oth.header()->ColumnCount())) { }
1014 
1016 {
1017  PyDecRef( mHeader );
1018  PyDecRef( mFields );
1019 }
1020 
1022 {
1023  return new PyPackedRow( *this );
1024 }
1025 
1027 {
1028  return v.VisitPackedRow( this );
1029 }
1030 
1031 bool PyPackedRow::SetField( uint32 index, PyRep* value )
1032 {
1033  if (!header()->VerifyValue( index, value ) ) {
1034  PyDecRef( value );
1035  return false;
1036  }
1037 
1038  mFields->SetItem( index, value );
1039  return true;
1040 }
1041 
1042 bool PyPackedRow::SetField( const char* colName, PyRep* value )
1043 {
1044  return SetField( header()->FindColumn( colName ), value );
1045 }
1046 
1048 {
1049  assert(false);
1050  return PyRep::hash();
1051 }
1052 
1054 {
1055  *mFields = *oth.mFields;
1056 
1057  return *this;
1058 }
1059 
1060 /************************************************************************/
1061 /* PyRep SubStruct Class */
1062 /************************************************************************/
1063 PySubStruct::PySubStruct( PyRep* t ) : PyRep( PyRep::PyTypeSubStruct ), mSub( t ) {}
1064 PySubStruct::PySubStruct( const PySubStruct& oth ) : PyRep( PyRep::PyTypeSubStruct ), mSub( oth.sub()->Clone() ) {}
1065 
1067 {
1068  PyDecRef( mSub );
1069 }
1070 
1072 {
1073  return new PySubStruct( *this );
1074 }
1075 
1077 {
1078  return v.VisitSubStruct( this );
1079 }
1080 
1081 /************************************************************************/
1082 /* PyRep SubStream Class */
1083 /************************************************************************/
1084 PySubStream::PySubStream(PyRep* rep ) : PyRep( PyRep::PyTypeSubStream ), mData( nullptr ), mDecoded( rep ) {}
1085 PySubStream::PySubStream(PyBuffer* buffer ): PyRep(PyRep::PyTypeSubStream), mData( buffer ), mDecoded( nullptr ) {}
1086 PySubStream::PySubStream(const PySubStream& oth ) : PyRep(PyRep::PyTypeSubStream),
1087  mData( oth.data() == nullptr ? nullptr : new PyBuffer( *oth.data() ) ),
1088  mDecoded( oth.decoded() == nullptr ? nullptr : oth.decoded()->Clone() )
1089 {
1090 
1091 }
1092 
1094 {
1095  PySafeDecRef( mData );
1097 }
1098 
1100 {
1101  return new PySubStream( *this );
1102 }
1103 
1105 {
1106  return v.VisitSubStream( this );
1107 }
1108 
1110 {
1111  if ((mDecoded == nullptr) or (mData != nullptr))
1112  return;
1113 
1114  Buffer* buf = new Buffer();
1115  if (!Marshal( mDecoded, *buf ) ) {
1116  sLog.Error( "Marshal", "Failed to marshal rep %p.", mDecoded );
1117  SafeDelete( buf );
1118  return;
1119  }
1120 
1121  // Move ownership of Buffer to PyBuffer
1122  mData = new PyBuffer( &buf );
1123 }
1124 
1126 {
1127  if ((mData == nullptr) or (mDecoded != nullptr))
1128  return;
1129 
1130  mDecoded = Unmarshal( mData->content() );
1131 }
1132 
1133 /************************************************************************/
1134 /* PyRep ChecksumedStream Class */
1135 /************************************************************************/
1137 : PyRep(PyRep::PyTypeChecksumedStream), mStream(t), mChecksum(sum) { }
1139 : PyRep(PyRep::PyTypeChecksumedStream), mStream(oth.stream()->Clone()), mChecksum( oth.checksum()) { }
1140 
1142 {
1143  PyDecRef( mStream );
1144 }
1145 
1147 {
1148  return new PyChecksumedStream( *this );
1149 }
1150 
1152 {
1153  return v.VisitChecksumedStream( this );
1154 }
1155 
1156 
1157 /************************************************************************/
1158 /* tuple large integer helper functions */
1159 /************************************************************************/
1161 {
1162  PyTuple* res = new PyTuple(1);
1163  res->SetItem(0, new PyLong(arg1));
1164  return res;
1165 }
1166 
1168 {
1169  PyTuple* res = new PyTuple(2);
1170  res->SetItem(0, new PyLong(arg1));
1171  res->SetItem(1, new PyLong(arg2));
1172  return res;
1173 }
1174 
1175 /************************************************************************/
1176 /* tuple string helper functions */
1177 /************************************************************************/
1178 PyTuple* new_tuple(const char* arg1)
1179 {
1180  PyTuple* res = new PyTuple(1);
1181  res->SetItem(0, new PyString(arg1));
1182  return res;
1183 }
1184 
1185 PyTuple* new_tuple(const char* arg1, const char* arg2)
1186 {
1187  PyTuple* res = new PyTuple(2);
1188  res->SetItem(0, new PyString(arg1));
1189  res->SetItem(1, new PyString(arg2));
1190  return res;
1191 }
1192 
1193 PyTuple* new_tuple(const char* arg1, const char* arg2, const char* arg3)
1194 {
1195  PyTuple* res = new PyTuple(3);
1196  res->SetItem(0, new PyString(arg1));
1197  res->SetItem(1, new PyString(arg2));
1198  res->SetItem(2, new PyString(arg3));
1199  return res;
1200 }
1201 
1202 /************************************************************************/
1203 /* mixed tuple helper functions */
1204 /************************************************************************/
1205 PyTuple* new_tuple(const char* arg1, const char* arg2, PyTuple* arg3)
1206 {
1207  PyTuple* res = new PyTuple(3);
1208  res->SetItem(0, new PyString(arg1));
1209  res->SetItem(1, new PyString(arg2));
1210  res->SetItem(2, arg3);
1211  return res;
1212 }
1213 
1214 PyTuple* new_tuple(const char* arg1, PyRep* arg2, PyRep* arg3)
1215 {
1216  PyTuple* res = new PyTuple(3);
1217  res->SetItem(0, new PyString(arg1));
1218  res->SetItem(1, arg2);
1219  res->SetItem(2, arg3);
1220  return res;
1221 }
1222 
1223 PyTuple* new_tuple(PyRep* arg1, PyRep* arg2, PyRep* arg3)
1224 {
1225  PyTuple* res = new PyTuple(3);
1226  res->SetItem(0, arg1);
1227  res->SetItem(1, arg2);
1228  res->SetItem(2, arg3);
1229  return res;
1230 }
1231 
1232 PyTuple* new_tuple( PyRep* arg1, PyRep* arg2 )
1233 {
1234  PyTuple* res = new PyTuple(2);
1235  res->SetItem(0, arg1);
1236  res->SetItem(1, arg2);
1237  return res;
1238 }
1239 
1241 {
1242  PyTuple* res = new PyTuple(1);
1243  res->SetItem(0, arg1);
1244  return res;
1245 }
dict_type *const mDict
Definition: PyRep.h:903
Base Python wire object.
Definition: PyRep.h:66
virtual bool VisitNone(const PyNone *rep)
Definition: PyVisitor.h:59
list_type & list()
Definition: PyRep.h:889
PyRep *const mStream
Definition: PyRep.h:1087
void clear()
Definition: PyRep.cpp:558
PyTuple * AsTuple()
Definition: PyRep.h:138
unsigned __int8 uint8
Definition: eve-compat.h:46
PyBool(bool i)
Definition: PyRep.cpp:320
PyWString(const char *str, size_t len)
Definition: PyRep.cpp:476
static std::string StringContent(PyRep *pRep)
Definition: PyRep.cpp:103
static PyTuple * _CreateHeader(PyTuple *args, PyDict *keywords, bool enclosed=false)
Definition: PyRep.cpp:971
double value() const
Definition: PyRep.h:309
itemID[count] Create count or of the specified() x() y(z)-Jump to the specified position in space.Stopped." ) COMMAND( translocate
virtual bool VisitTuple(const PyTuple *rep)
the nested types Visitor
Definition: PyVisitor.cpp:36
#define _log(type, fmt,...)
Definition: logsys.h:124
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:450
void clear()
Definition: PyRep.cpp:680
PyTuple & operator=(const PyTuple &oth)
Definition: PyRep.cpp:567
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:804
PyRep * GetItem(size_t index) const
Returns Python object.
Definition: PyRep.h:602
Python string.
Definition: PyRep.h:430
int32 value() const
Definition: PyRep.h:247
PyRep * GetItemString(const char *key) const
Obtains database entry based on given key string.
Definition: PyRep.cpp:702
virtual bool VisitSubStream(const PySubStream *rep)
Definition: PyVisitor.cpp:119
PyBool * AsBool()
Definition: PyRep.h:128
Python's dictionary.
Definition: PyRep.h:719
const Buffer & content() const
Get the const PyBuffer content.
Definition: PyRep.h:407
size_t size() const
Definition: PyRep.h:591
DBRowDescriptor * header() const
Definition: PyRep.h:983
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:156
virtual bool VisitDict(const PyDict *rep)
Definition: PyVisitor.cpp:57
virtual bool VisitPackedRow(const PyPackedRow *rep)
PackedRow type visitor.
Definition: PyVisitor.cpp:99
PyTuple * GetArgs() const
Definition: PyRep.cpp:835
const std::string & content() const
Get the PyWString content.
Definition: PyRep.h:499
static PyTuple * _CreateHeader(PyToken *type, PyTuple *args, bool enclosed=false)
Definition: PyRep.cpp:867
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:1099
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:323
storage_type::iterator iterator
Definition: PyRep.h:749
list_type *const mList
Definition: PyRep.h:902
virtual bool VisitString(const PyString *rep)
Definition: PyVisitor.h:61
virtual bool VisitWString(const PyWString *rep)
Definition: PyVisitor.h:62
PyPackedRow & operator=(const PyPackedRow &oth)
Definition: PyRep.cpp:1053
storage_type::const_iterator const_iterator
Definition: PyRep.h:572
PyString * mType
Definition: PyRep.h:850
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:799
PyRep * FindKeyword(const char *keyword) const
Definition: PyRep.cpp:959
A reference-counted object.
Definition: RefPtr.h:48
virtual ~PySubStream()
Definition: PyRep.cpp:1093
bool IsString() const
Definition: PyRep.h:105
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:617
PyObjectEx_Type2(PyTuple *args, PyDict *keywords, bool enclosed=false)
Definition: PyRep.cpp:942
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:773
Python floating point number.
Definition: PyRep.h:292
Python wide string.
Definition: PyRep.h:475
storage_type *const mFields
Definition: PyRep.h:1001
virtual ~PyPackedRow()
Definition: PyRep.cpp:1015
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:529
bool value() const
Definition: PyRep.h:340
const_iterator begin() const
Definition: PyRep.h:660
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:486
storage_type::iterator iterator
Definition: PyRep.h:643
PyList & operator=(const PyList &oth)
Definition: PyRep.cpp:637
storage_type::const_iterator const_iterator
Definition: PyRep.h:644
static uint32 IntegerValueU32(PyRep *pRep)
Definition: PyRep.cpp:134
bool Marshal(const PyRep *rep, Buffer &into)
Definition: EVEMarshal.cpp:36
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:376
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:241
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:455
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:166
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:675
virtual bool VisitToken(const PyToken *rep)
Definition: PyVisitor.h:63
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:1151
storage_type items
Definition: PyRep.h:814
Python tuple.
Definition: PyRep.h:567
virtual bool VisitReal(const PyFloat *rep)
Definition: PyVisitor.h:57
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:1104
PyToken * GetType() const
Definition: PyRep.cpp:829
int32 mHashCache
Definition: PyRep.h:466
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:349
PyList(size_t item_count=0)
Definition: PyRep.cpp:608
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:1146
virtual ~PyDict()
Definition: PyRep.cpp:660
PyLong * AsLong()
Definition: PyRep.h:124
virtual ~PySubStruct()
Definition: PyRep.cpp:1066
const PyType mType
Definition: PyRep.h:223
PyRep *const mSub
Definition: PyRep.h:1026
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
virtual bool VisitLong(const PyLong *rep)
Definition: PyVisitor.h:56
signed __int32 int32
Definition: eve-compat.h:49
* args
Python boolean.
Definition: PyRep.h:323
#define LONG_BIT_PyLong_SHIFT
const double mValue
Definition: PyRep.h:315
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
PyRep *const mArguments
Definition: PyRep.h:851
const int64 mValue
Definition: PyRep.h:284
PyString(const char *str)
Definition: PyRep.cpp:430
size_t size() const
Obtains length of the buffer.
Definition: PyRep.cpp:422
virtual bool VisitObjectEx(const PyObjectEx *rep)
Definition: PyVisitor.cpp:78
Python extended object.
Definition: PyRep.h:861
PyObject(const char *type, PyRep *args)
Definition: PyRep.cpp:762
Generic class for buffers.
Definition: Buffer.h:40
void DecodeData() const
Definition: PyRep.cpp:1125
PyRep *const mHeader
Definition: PyRep.h:899
PyObjectEx_Type1(PyToken *type, PyTuple *args, bool enclosed=false)
Definition: PyRep.cpp:820
Python object.
Definition: PyRep.h:826
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:548
Python object "blue.DBRowDescriptor".
Definition: PyDatabase.h:41
PyTuple * new_tuple(int64 arg1)
Definition: PyRep.cpp:1160
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:1076
Python's "none".
Definition: PyRep.h:352
virtual bool VisitBoolean(const PyBool *rep)
Definition: PyVisitor.h:58
virtual ~PyString()
Definition: PyRep.cpp:444
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:187
#define codelog(type, fmt,...)
Definition: logsys.h:128
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
PyRep * GetItem(PyRep *key) const
Obtains a database entry based on given key object.
Definition: PyRep.cpp:691
PyLong(const int64 i)
Definition: PyRep.cpp:179
storage_type items
Definition: PyRep.h:708
PyNone()
Definition: PyRep.cpp:336
virtual bool VisitSubStruct(const PySubStruct *rep)
wrapper types Visitor
Definition: PyVisitor.cpp:112
Python integer.
Definition: PyRep.h:231
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:682
PyDict * AsDict()
Definition: PyRep.h:142
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:501
PyString * AsString()
Definition: PyRep.h:132
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:670
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:161
PyInt(const int32 i)
Definition: PyRep.cpp:153
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:584
dict_type & dict()
Definition: PyRep.h:892
storage_type::iterator iterator
Definition: PyRep.h:571
#define PyStatic
Definition: PyRep.h:1209
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:1026
PyRep * FindKeyword(const char *keyword) const
Definition: PyRep.cpp:853
virtual int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:96
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:328
PyChecksumedStream(PyRep *t, uint32 sum)
Definition: PyRep.cpp:1136
#define PyDecRef(op)
Definition: PyRep.h:57
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:256
PyToken(const char *token)
Definition: PyRep.cpp:517
#define Py_IS_INFINITY(X)
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:246
virtual bool VisitInteger(const PyInt *rep)
primitive data visitors
Definition: PyVisitor.h:55
PyTuple(size_t item_count)
Definition: PyRep.cpp:537
void clear()
Definition: PyRep.cpp:627
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:182
PyBuffer * mData
Definition: PyRep.h:1060
PyDict * GetKeywords() const
Definition: PyRep.cpp:953
unsigned __int32 uint32
Definition: eve-compat.h:50
int64 value() const
Definition: PyRep.h:278
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:386
PyType
Python wire object types.
Definition: PyRep.h:72
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:1071
const std::string mValue
Definition: PyRep.h:465
const char *const s_mTypeString[]
Definition: PyRep.cpp:39
PyRep * Unmarshal(const Buffer &data)
Turns marshal stream into Python object.
int32 mHashCache
Definition: PyRep.h:514
const int32 mValue
Definition: PyRep.h:253
const_iterator begin() const
Definition: PyRep.h:766
Python token (eg. class name).
Definition: PyRep.h:522
const Buffer *const mValue
Definition: PyRep.h:421
virtual ~PyObject()
Definition: PyRep.cpp:767
PyObjectEx(bool is_type_2, PyRep *header)
Definition: PyRep.cpp:786
virtual ~PyTuple()
Definition: PyRep.cpp:542
PySubStruct(PyRep *t)
Definition: PyRep.cpp:1063
Wrapper class for PyObjectEx of type 1.
Definition: PyRep.h:911
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:192
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:460
virtual ~PyChecksumedStream()
Definition: PyRep.cpp:1141
bool IsNone() const
Definition: PyRep.h:111
virtual bool VisitObject(const PyObject *rep)
Object type visitor.
Definition: PyVisitor.cpp:69
signed __int64 int64
Definition: eve-compat.h:51
LogType
Definition: logsys.h:59
const_iterator end() const
Definition: PyRep.h:661
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:524
storage_type::const_iterator const_iterator
Definition: PyRep.h:750
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:1021
const std::string mValue
Definition: PyRep.h:513
#define INT32_MAX
Definition: PyRep.cpp:253
bool IsBool() const
Definition: PyRep.h:103
bool IsLong() const
Definition: PyRep.h:101
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:491
PyRep * header() const
Definition: PyRep.h:886
size_type size() const
Definition: Buffer.h:610
bool IsFloat() const
Definition: PyRep.h:102
PyObjectEx & operator=(const PyObjectEx &oth)
Definition: PyRep.cpp:809
bool SetField(uint32 index, PyRep *value)
Definition: PyRep.cpp:1031
PyFloat(const double &i)
Definition: PyRep.cpp:238
PyRep(PyType t)
Definition: PyRep.cpp:73
#define PyLong_MASK
virtual ~PyList()
Definition: PyRep.cpp:611
PyTuple * GetArgs() const
Definition: PyRep.cpp:947
PyDict()
Definition: PyRep.cpp:657
PyPackedRow(DBRowDescriptor *header)
Definition: PyRep.cpp:1010
PySubStream(PyRep *rep)
Definition: PyRep.cpp:1084
virtual ~PyObjectEx()
Definition: PyRep.cpp:791
int32 hash() const
virtual function to generate a hash value of a object.
Definition: PyRep.cpp:1047
const std::string & content() const
Get the PyString content.
Definition: PyRep.h:458
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:553
const_iterator end() const
Definition: PyRep.h:767
size_t size() const
Definition: PyRep.h:663
virtual ~PyBuffer()
Definition: PyRep.cpp:371
#define PySafeDecRef(op)
Definition: PyRep.h:61
Python buffer.
Definition: PyRep.h:382
Packed row.
Definition: PyRep.h:961
bool IsInt() const
Definition: PyRep.h:100
storage_type items
Definition: PyRep.h:628
PyRep * Clone() const
Clones object.
Definition: PyRep.cpp:339
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:622
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type() key(value)-Send an OnRemoteMessage" ) COMMAND( setbpattr
int32 mHashCache
Definition: PyRep.h:422
static int64 IntegerValue(PyRep *pRep)
Definition: PyRep.cpp:118
const_iterator end() const
Definition: PyRep.h:589
PyDict & operator=(const PyDict &oth)
Definition: PyRep.cpp:743
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:344
DBRowDescriptor *const mHeader
Definition: PyRep.h:1000
const_iterator begin() const
Definition: PyRep.h:588
PyFloat * AsFloat()
Definition: PyRep.h:126
PyInt * AsInt()
Definition: PyRep.h:122
PyBuffer(size_t len, const uint8 &value)
Definition: PyRep.cpp:359
size_t size() const
Obtains length of string.
Definition: PyRep.cpp:496
virtual bool VisitBuffer(const PyBuffer *rep)
Definition: PyVisitor.h:60
PyToken * AsToken()
Definition: PyRep.h:136
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:778
entityID heal the character with the entityID note giving you detailed ship status information gives a list of all dynamic entities and players and their destinyState in this bubble shows some current destiny variables save all items
PyRep * mDecoded
Definition: PyRep.h:1061
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
bool visit(PyVisitor &v) const
Visits object.
Definition: PyRep.cpp:381
const char * TypeString() const
Definition: PyRep.cpp:76
virtual bool VisitList(const PyList *rep)
Definition: PyVisitor.cpp:47
PyDict * GetKeywords() const
Definition: PyRep.cpp:841
void EncodeData() const
Definition: PyRep.cpp:1109
Python list.
Definition: PyRep.h:639
virtual bool visit(PyVisitor &v) const =0
Visits object.
PyWString * AsWString()
Definition: PyRep.h:134
Python long integer.
Definition: PyRep.h:261
bool IsWString() const
Definition: PyRep.h:106
virtual bool VisitChecksumedStream(const PyChecksumedStream *rep)
Definition: PyVisitor.cpp:133