static PyObject* PythonQtClassWrapper_alloc(PyTypeObject *self, Py_ssize_t nitems)
{
  // call the default type alloc
  PyObject* obj = PyType_Type.tp_alloc(self, nitems);

  // take current class type, if we are called via newPythonQtClassWrapper()
  PythonQtClassWrapper* wrap = (PythonQtClassWrapper*)obj;
  wrap->_classInfo = PythonQt::priv()->currentClassInfoForClassWrapperCreation();
  if (wrap->_classInfo) {
    initializeSlots(wrap);
  }

  return obj;
}
Пример #2
0
/* 
*	allocating the resources for the game+initiallizing it
*	throws calloc errors
*/
void allocateChess(int isGUI)
{
	mainGame = (Game*)malloc(sizeof(Game));
	if(mainGame==NULL){ calloc_error(); standart_fail=true; return;}
	/* setting startingGameSetting to save the starting state */
	mainGame->gameInfo=(game *)malloc(sizeof(game));
	if(mainGame->gameInfo==NULL){
		malloc_error(); standart_fail=1;
		free(mainGame); 
		return;
	}
	mainGame->gameInfo->boardPointer = (chessboard *)calloc((BOARD_SIZE * BOARD_SIZE), sizeof(char));
	if(mainGame->gameInfo->boardPointer==NULL){ 
		calloc_error(); standart_fail=1; 
		free(mainGame->gameInfo); free(mainGame); 
		return;
	}
	if(isGUI){
		mainGame->startingGameSettings=(game *)malloc(sizeof(game));
		if(mainGame->startingGameSettings==NULL){ 
			malloc_error(); standart_fail=1; 
			free(mainGame->gameInfo->boardPointer); free(mainGame->gameInfo); free(mainGame); 
			return;
		}
	
		mainGame->startingGameSettings->boardPointer=(chessboard *)calloc((BOARD_SIZE * BOARD_SIZE), sizeof(char));
		if(mainGame->startingGameSettings->boardPointer==NULL){
			malloc_error(); standart_fail=1; 
			free(mainGame->startingGameSettings); free(mainGame->gameInfo->boardPointer); free(mainGame->gameInfo); free(mainGame); 
			return;
		}
		initializeSlots();
		if(standart_fail){ deleteChessGame(isGUI); return;}
	}
	initializeChess(isGUI);
	if(standart_fail){ 
		deleteChessGame(isGUI); 
		if(isGUI){deleteSlots(SLOT_NUM);}
		return;
	}
}