mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 14:29:18 +02:00
LCD Screens in python
Merge with python branch
This commit is contained in:
@@ -4,9 +4,11 @@ IndentWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlignTrailingComments: false
|
||||
BreakBeforeBraces: Allman
|
||||
BreakBeforeTernaryOperators: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
ColumnLimit: 100
|
||||
---
|
||||
|
||||
11
AdvSound.cpp
11
AdvSound.cpp
@@ -32,10 +32,12 @@ TAdvancedSound::~TAdvancedSound()
|
||||
// SoundShut.Stop();
|
||||
}
|
||||
|
||||
void TAdvancedSound::Free() {}
|
||||
void TAdvancedSound::Free()
|
||||
{
|
||||
}
|
||||
|
||||
void TAdvancedSound::Init(char *NameOn, char *Name, char *NameOff,
|
||||
double DistanceAttenuation, vector3 pPosition)
|
||||
void TAdvancedSound::Init(char *NameOn, char *Name, char *NameOff, double DistanceAttenuation,
|
||||
vector3 pPosition)
|
||||
{
|
||||
SoundStart.Init(NameOn, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true);
|
||||
SoundCommencing.Init(Name, DistanceAttenuation, pPosition.x, pPosition.y, pPosition.z, true);
|
||||
@@ -131,8 +133,7 @@ void TAdvancedSound::Update(bool ListenerInside, vector3 NewPosition)
|
||||
}
|
||||
}
|
||||
|
||||
void TAdvancedSound::UpdateAF(double A, double F, bool ListenerInside,
|
||||
vector3 NewPosition)
|
||||
void TAdvancedSound::UpdateAF(double A, double F, bool ListenerInside, vector3 NewPosition)
|
||||
{ // update, ale z amplituda i czestotliwoscia
|
||||
if ((State == ss_Commencing) && (SoundCommencing.AM > 0))
|
||||
{
|
||||
|
||||
@@ -14,9 +14,14 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "AirCoupler.h"
|
||||
#include "Timer.h"
|
||||
|
||||
TAirCoupler::TAirCoupler() { Clear(); }
|
||||
TAirCoupler::TAirCoupler()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
TAirCoupler::~TAirCoupler() {}
|
||||
TAirCoupler::~TAirCoupler()
|
||||
{
|
||||
}
|
||||
|
||||
int TAirCoupler::GetStatus()
|
||||
{ // zwraca 1, jeœli istnieje model prosty, 2 gdy skoœny
|
||||
|
||||
@@ -28,6 +28,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
TAnimAdvanced::TAnimAdvanced(){};
|
||||
|
||||
TAnimAdvanced::~TAnimAdvanced(){
|
||||
// delete[] pVocaloidMotionData; //plik został zmodyfikowany
|
||||
};
|
||||
@@ -179,7 +180,7 @@ void TAnimContainer::AnimSetVMD(double fNewSpeed)
|
||||
//-+-+ - dłoń ma w górze zamiast na pasie w pozycji początkowej
|
||||
//+--+ - głowa do tyłu (broda w górę) w pozycji początkowej
|
||||
//--++ - pozycja początkowa dobra, trąca u góry, ale z rękami jakoś nie tak, kółko w
|
||||
//przeciwną stronę
|
||||
// przeciwną stronę
|
||||
//++++ - kładzie się brzuchem do góry
|
||||
//-+++ - ręce w górze na początku, zamiast w dół, łokieć jakby w przeciwną stronę
|
||||
//+-++ - nie podnosi ręki do głowy
|
||||
@@ -684,10 +685,12 @@ void TAnimModel::RenderAlphaVBO(vector3 *vPosition)
|
||||
//---------------------------------------------------------------------------
|
||||
bool TAnimModel::TerrainLoaded()
|
||||
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
|
||||
return (this ? pModel != NULL : false); };
|
||||
return (this ? pModel != NULL : false);
|
||||
};
|
||||
int TAnimModel::TerrainCount()
|
||||
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
|
||||
return pModel ? pModel->TerrainCount() : 0; };
|
||||
return pModel ? pModel->TerrainCount() : 0;
|
||||
};
|
||||
TSubModel *__fastcall TAnimModel::TerrainSquare(int n)
|
||||
{ // pobieranie wskaźników do pierwszego submodelu
|
||||
return pModel ? pModel->TerrainSquare(n) : 0;
|
||||
|
||||
15
AnimModel.h
15
AnimModel.h
@@ -80,7 +80,10 @@ class TAnimContainer
|
||||
// std::string(pSubModel?pSubModel->asName.c_str():""); };
|
||||
// std::string inline GetName() { return std::string(pSubModel?pSubModel->pName:"");
|
||||
// };
|
||||
char *__fastcall NameGet() { return (pSubModel ? pSubModel->pName : NULL); };
|
||||
char *__fastcall NameGet()
|
||||
{
|
||||
return (pSubModel ? pSubModel->pName : NULL);
|
||||
};
|
||||
// void SetRotateAnim(vector3 vNewRotateAxis, double fNewDesiredAngle, double
|
||||
// fNewRotateSpeed, bool bResetAngle=false);
|
||||
void SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSpeed);
|
||||
@@ -90,7 +93,10 @@ class TAnimContainer
|
||||
void UpdateModel();
|
||||
void UpdateModelIK();
|
||||
bool InMovement(); // czy w trakcie animacji?
|
||||
double _fastcall AngleGet() { return vRotateAngles.z; }; // jednak ostatnia, T3D ma inny uk³ad
|
||||
double _fastcall AngleGet()
|
||||
{
|
||||
return vRotateAngles.z;
|
||||
}; // jednak ostatnia, T3D ma inny uk³ad
|
||||
vector3 _fastcall TransGet()
|
||||
{
|
||||
return vector3(-vTranslation.x, vTranslation.z, vTranslation.y);
|
||||
@@ -101,7 +107,10 @@ class TAnimContainer
|
||||
pSubModel->WillBeAnimated();
|
||||
};
|
||||
void EventAssign(TEvent *ev);
|
||||
TEvent *__fastcall Event() { return evDone; };
|
||||
TEvent *__fastcall Event()
|
||||
{
|
||||
return evDone;
|
||||
};
|
||||
};
|
||||
|
||||
class TAnimAdvanced
|
||||
|
||||
10
Button.h
10
Button.h
@@ -25,7 +25,10 @@ class TButton
|
||||
TButton();
|
||||
~TButton();
|
||||
void Clear(int i = -1);
|
||||
inline void FeedbackBitSet(int i) { iFeedbackBit = 1 << i; };
|
||||
inline void FeedbackBitSet(int i)
|
||||
{
|
||||
iFeedbackBit = 1 << i;
|
||||
};
|
||||
inline void Turn(bool to)
|
||||
{
|
||||
bOn = to;
|
||||
@@ -46,7 +49,10 @@ class TButton
|
||||
bOn = !bOn;
|
||||
Update();
|
||||
};
|
||||
inline bool Active() { return (pModelOn) || (pModelOff); };
|
||||
inline bool Active()
|
||||
{
|
||||
return (pModelOn) || (pModelOff);
|
||||
};
|
||||
void Init(AnsiString asName, TModel3d *pModel, bool bNewOn = false);
|
||||
void Load(TQueryParserComp *Parser, TModel3d *pModel1, TModel3d *pModel2 = NULL);
|
||||
};
|
||||
|
||||
5
Camera.h
5
Camera.h
@@ -38,7 +38,10 @@ class TCamera
|
||||
vector3 CrossPos;
|
||||
double CrossDist;
|
||||
void Init(vector3 NPos, vector3 NAngle);
|
||||
void Reset() { Pitch = Yaw = Roll = 0; };
|
||||
void Reset()
|
||||
{
|
||||
Pitch = Yaw = Roll = 0;
|
||||
};
|
||||
void OnCursorMove(double x, double y);
|
||||
void Update();
|
||||
vector3 GetDirection();
|
||||
|
||||
15
Console.cpp
15
Console.cpp
@@ -274,7 +274,10 @@ void Console::BitsUpdate(int mask)
|
||||
}
|
||||
};
|
||||
|
||||
bool Console::Pressed(int x) { return Global::bActive && (GetKeyState(x) < 0); }; // na razie tak - czyta się tylko klawiatura
|
||||
bool Console::Pressed(int x)
|
||||
{ // na razie tak - czyta się tylko klawiatura
|
||||
return Global::bActive && (GetKeyState(x) < 0);
|
||||
};
|
||||
|
||||
void Console::ValueSet(int x, double y)
|
||||
{ // ustawienie wartości (y) na kanale analogowym (x)
|
||||
@@ -353,5 +356,11 @@ void Console::OnKeyUp(int k)
|
||||
else
|
||||
iButton[char(k) >> 5] &= ~(1 << (k & 31)); // wyłącz monostabilny podstawowy
|
||||
};
|
||||
int Console::KeyDownConvert(int k) { return int(ktTable[k & 0x3FF].iDown); };
|
||||
int Console::KeyUpConvert(int k) { return int(ktTable[k & 0x3FF].iUp); };
|
||||
int Console::KeyDownConvert(int k)
|
||||
{
|
||||
return int(ktTable[k & 0x3FF].iDown);
|
||||
};
|
||||
int Console::KeyUpConvert(int k)
|
||||
{
|
||||
return int(ktTable[k & 0x3FF].iUp);
|
||||
};
|
||||
|
||||
@@ -48,4 +48,7 @@ bool TLPT::Connect(int port)
|
||||
return bool(OutPort);
|
||||
};
|
||||
|
||||
void TLPT::Out(int x) { OutPort(address, x); }; // wys³anie bajtu do portu
|
||||
void TLPT::Out(int x)
|
||||
{ // wys³anie bajtu do portu
|
||||
OutPort(address, x);
|
||||
};
|
||||
|
||||
@@ -39,7 +39,10 @@ TPoKeys55::TPoKeys55()
|
||||
bNoError = true;
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
TPoKeys55::~TPoKeys55() { Close(); };
|
||||
TPoKeys55::~TPoKeys55()
|
||||
{
|
||||
Close();
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
bool TPoKeys55::Close()
|
||||
{ // roz³¹czenie komunikacji
|
||||
@@ -202,8 +205,7 @@ bool TPoKeys55::Connect()
|
||||
return false;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4,
|
||||
unsigned char b5)
|
||||
bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4, unsigned char b5)
|
||||
{
|
||||
DWORD BytesWritten = 0;
|
||||
OutputBuffer[0] = 0; // The first byte is the "Report ID" and does not get transmitted over the
|
||||
|
||||
@@ -28,8 +28,7 @@ class TPoKeys55
|
||||
~TPoKeys55();
|
||||
bool Connect();
|
||||
bool Close();
|
||||
bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0,
|
||||
unsigned char b5 = 0);
|
||||
bool Write(unsigned char c, unsigned char b3, unsigned char b4 = 0, unsigned char b5 = 0);
|
||||
bool Read();
|
||||
bool ReadLoop(int i);
|
||||
AnsiString Version();
|
||||
|
||||
3
Data.h
3
Data.h
@@ -17,7 +17,8 @@ struct TDist
|
||||
{
|
||||
int x, y;
|
||||
};
|
||||
const TDist SectorOrder[] = { // tabela wspó³rzêdnych sektorów, posortowana wg odleg³oœci
|
||||
const TDist SectorOrder[] = {
|
||||
// tabela wspó³rzêdnych sektorów, posortowana wg odleg³oœci
|
||||
{0, 0}, // 0.00
|
||||
{1, 0}, // 1.00
|
||||
{0, 1}, // 1.00
|
||||
|
||||
79
Driver.cpp
79
Driver.cpp
@@ -87,7 +87,8 @@ const double HardAcceleration = 0.9;
|
||||
const double PrepareTime = 2.0; //[s] przebłyski świadomości przy odpalaniu
|
||||
bool WriteLogFlag = false;
|
||||
|
||||
AnsiString StopReasonTable[] = { // przyczyny zatrzymania ruchu AI
|
||||
AnsiString StopReasonTable[] = {
|
||||
// przyczyny zatrzymania ruchu AI
|
||||
"", // stopNone, //nie ma powodu - powinien jechać
|
||||
"Off", // stopSleep, //nie został odpalony, to nie pojedzie
|
||||
"Semaphore", // stopSem, //semafor zamknięty
|
||||
@@ -217,7 +218,7 @@ bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len)
|
||||
if ((i = iFlags & 0xF0000000) != 0)
|
||||
{ // jeśli skrzyżowanie, ograniczyć prędkość przy skręcaniu
|
||||
if (abs(i) > 0x10000000) //±1 to jazda na wprost, ±2 nieby też, ale z przecięciem
|
||||
//głównej drogi - chyba że jest równorzędne...
|
||||
// głównej drogi - chyba że jest równorzędne...
|
||||
fVelNext = 30.0; // uzależnić prędkość od promienia; albo niech będzie
|
||||
// ograniczona w skrzyżowaniu (velocity z ujemną wartością)
|
||||
if ((iFlags & 32) == 0) // jeśli nie wjechał
|
||||
@@ -624,8 +625,7 @@ void TController::TableCheck(double fDistance)
|
||||
}
|
||||
};
|
||||
|
||||
TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fNext,
|
||||
double &fAcc)
|
||||
TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc)
|
||||
{ // ustalenie parametrów, zwraca typ komendy, jeśli sygnał podaje prędkość do jazdy
|
||||
// fVelDes - prędkość zadana
|
||||
// fDist - dystans w jakim należy rozważyć ruch
|
||||
@@ -663,7 +663,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
if (sSpeedTable[i].fDist <
|
||||
200.0) // przy 160km/h jedzie 44m/s, to da dokładność rzędu 5 sekund
|
||||
{ // zaliczamy posterunek w pewnej odległości przed (choć W4 nie zasłania
|
||||
// już semafora)
|
||||
// już semafora)
|
||||
#if LOGSTOPS
|
||||
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + ": at " +
|
||||
AnsiString(GlobalTime->hh) + ":" + AnsiString(GlobalTime->mm) +
|
||||
@@ -912,7 +912,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
if (sSpeedTable[i].fDist < 0.0) // jeśli wskaźnik został minięty
|
||||
{
|
||||
VelSignal = v; //!!! ustawienie, gdy przejechany jest lepsze niż wcale,
|
||||
//ale to jeszcze nie to
|
||||
// ale to jeszcze nie to
|
||||
// iStationStart=TrainParams->StationIndex; //zaktualizować
|
||||
// wyświetlanie rozkładu
|
||||
}
|
||||
@@ -977,7 +977,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
if (sSpeedTable[i].fDist < 0.0) // jeśli przejechany
|
||||
{
|
||||
VelSignal = v; //!!! ustawienie, gdy przejechany jest lepsze niż
|
||||
//wcale, ale to jeszcze nie to
|
||||
// wcale, ale to jeszcze nie to
|
||||
sSpeedTable[i].iFlags =
|
||||
0; // to można usunąć (nie mogą być usuwane w skanowaniu)
|
||||
}
|
||||
@@ -999,7 +999,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
if (sSpeedTable[i].fDist < 0.0) // jeśli przejechany
|
||||
{
|
||||
VelSignal = v; //!!! ustawienie, gdy przejechany jest lepsze niż
|
||||
//wcale, ale to jeszcze nie to
|
||||
// wcale, ale to jeszcze nie to
|
||||
if (sSpeedTable[i].iFlags & 0x100) // jeśli semafor
|
||||
if ((sSpeedTable[i].evEvent != eSignSkip) ?
|
||||
true :
|
||||
@@ -1612,10 +1612,10 @@ bool TController::CheckVehicles(TOrders user)
|
||||
else if (OrderCurrentGet() == Disconnect)
|
||||
if (mvOccupied->ActiveDir > 0) // jak ma kierunek do przodu
|
||||
Lights(16, 0); //światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić
|
||||
//odczepionego ze światłem
|
||||
// odczepionego ze światłem
|
||||
else // jak dociska
|
||||
Lights(0, 16); //światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić
|
||||
//odczepionego ze światłem
|
||||
// odczepionego ze światłem
|
||||
}
|
||||
else // Ra 2014-02: lepiej tu niż w pętli obsługującej komendy, bo tam się zmieni informacja
|
||||
// o składzie
|
||||
@@ -2823,7 +2823,7 @@ bool TController::PutCommand(AnsiString NewCommand, double NewValue1, double New
|
||||
else if (NewCommand == "Shunt")
|
||||
{ // NewValue1 - ilość wagonów (-1=wszystkie); NewValue2: 0=odczep, 1..63=dołącz, -1=bez zmian
|
||||
//-3,-y - podłączyć do całego stojącego składu (sprzęgiem y>=1), zmienić kierunek i czekać w
|
||||
//trybie pociągowym
|
||||
// trybie pociągowym
|
||||
//-2,-y - podłączyć do całego stojącego składu (sprzęgiem y>=1), zmienić kierunek i czekać
|
||||
//-2, y - podłączyć do całego stojącego składu (sprzęgiem y>=1) i czekać
|
||||
//-1,-y - podłączyć do całego stojącego składu (sprzęgiem y>=1) i jechać w powrotną stronę
|
||||
@@ -3962,8 +3962,8 @@ bool TController::UpdateSituation(double dt)
|
||||
// składowa styczna grawitacji
|
||||
else
|
||||
AbsAccS = iDirection * mvOccupied->AccS; // przyspieszenie chwilowe, liczone
|
||||
// jako różnica skierowanej prędkości w
|
||||
// czasie
|
||||
// jako różnica skierowanej prędkości w
|
||||
// czasie
|
||||
// if (mvOccupied->V<0.0) AbsAccS=-AbsAccS; //Ra 2014-03: to trzeba przemyśleć
|
||||
// if (vel<0) //jeżeli się stacza w tył; 2014-03: to jest bez sensu, bo vel>=0
|
||||
// AbsAccS=-AbsAccS; //to przyspieszenie też działa wtedy w nieodpowiednią stronę
|
||||
@@ -3977,12 +3977,12 @@ bool TController::UpdateSituation(double dt)
|
||||
// ustalanie zadanego przyspieszenia
|
||||
//(ActualProximityDist) - odległość do miejsca zmniejszenia prędkości
|
||||
//(AccPreferred) - wynika z psychyki oraz uwzglęnia już ewentualne zderzenie z
|
||||
//pojazdem z przodu, ujemne gdy należy hamować
|
||||
// pojazdem z przodu, ujemne gdy należy hamować
|
||||
//(AccDesired) - uwzględnia sygnały na drodze ruchu, ujemne gdy należy hamować
|
||||
//(fAccGravity) - chwilowe przspieszenie grawitacyjne, ujemne działa przeciwnie do
|
||||
//zadanego kierunku jazdy
|
||||
// zadanego kierunku jazdy
|
||||
//(AbsAccS) - chwilowe przyspieszenie pojazu (uwzględnia grawitację), ujemne działa
|
||||
//przeciwnie do zadanego kierunku jazdy
|
||||
// przeciwnie do zadanego kierunku jazdy
|
||||
//(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS)
|
||||
// if ((VelNext>=0.0)&&(ActualProximityDist>=0)&&(mvOccupied->Vel>=VelNext)) //gdy
|
||||
// zbliza sie i jest za szybko do NOWEGO
|
||||
@@ -4048,7 +4048,7 @@ bool TController::UpdateSituation(double dt)
|
||||
(25.92 * (ActualProximityDist +
|
||||
0.1)); //-fMinProximityDist));//-0.1;
|
||||
////mniejsze opóźnienie przy
|
||||
//małej różnicy
|
||||
// małej różnicy
|
||||
ReactionTime = 0.1; // i orientuj się szybciej, jak masz stanąć
|
||||
}
|
||||
else if (vel < VelNext + fVelPlus) // jeśli niewielkie
|
||||
@@ -4103,7 +4103,7 @@ bool TController::UpdateSituation(double dt)
|
||||
AccDesired = AccPreferred; // dociagnij do semafora;
|
||||
else
|
||||
VelDesired = 0.0; //,AccDesired=-fabs(fAccGravity); //stoj (hamuj z siłą
|
||||
//równą składowej stycznej grawitacji)
|
||||
// równą składowej stycznej grawitacji)
|
||||
}
|
||||
else
|
||||
VelDesired = 0.0; // VelNext=0 i stoi bliżej niż fMaxProximityDist
|
||||
@@ -4564,9 +4564,15 @@ void TController::OrdersDump()
|
||||
}
|
||||
};
|
||||
|
||||
TOrders TController::OrderCurrentGet() { return OrderList[OrderPos]; }
|
||||
TOrders TController::OrderCurrentGet()
|
||||
{
|
||||
return OrderList[OrderPos];
|
||||
}
|
||||
|
||||
TOrders TController::OrderNextGet() { return OrderList[OrderPos + 1]; }
|
||||
TOrders TController::OrderNextGet()
|
||||
{
|
||||
return OrderList[OrderPos + 1];
|
||||
}
|
||||
|
||||
void TController::OrdersInit(double fVel)
|
||||
{ // wypełnianie tabelki rozkazów na podstawie rozkładu
|
||||
@@ -4876,7 +4882,7 @@ TCommandType TController::BackwardScan()
|
||||
(mvOccupied->Vel > 0.0) && (OrderCurrentGet() != Shunt) :
|
||||
false)
|
||||
{ // jeśli semafor jest daleko, a pojazd jedzie, to informujemy o
|
||||
// zmianie prędkości
|
||||
// zmianie prędkości
|
||||
// jeśli jedzie manewrowo, musi dostać SetVelocity, żeby sie na pociągowy przełączył
|
||||
// Mechanik->PutCommand("SetProximityVelocity",scandist,vmechmax,sl);
|
||||
#if LOGBACKSCAN
|
||||
@@ -4892,7 +4898,7 @@ TCommandType TController::BackwardScan()
|
||||
// if ((MoverParameters->Vel==0.0)||(vmechmax==0.0)) //jeśli stoi lub ma
|
||||
// stanąć/stać
|
||||
{ // semafor na tym torze albo lokomtywa stoi, a ma ruszyć, albo ma
|
||||
// stanąć, albo nie ruszać
|
||||
// stanąć, albo nie ruszać
|
||||
// stop trzeba powtarzać, bo inaczej zatrąbi i pojedzie sam
|
||||
// PutCommand("SetVelocity",vmechmax,e->Params[9].asMemCell->Value2(),&sl,stopSem);
|
||||
#if LOGBACKSCAN
|
||||
@@ -4913,7 +4919,7 @@ TCommandType TController::BackwardScan()
|
||||
{ // jeśli tarcza jest daleko, to:
|
||||
//- jesli pojazd jedzie, to informujemy o zmianie prędkości
|
||||
//- jeśli stoi, to z własnej inicjatywy może podjechać pod zamkniętą
|
||||
//tarczę
|
||||
// tarczę
|
||||
if (mvOccupied->Vel > 0.0) // tylko jeśli jedzie
|
||||
{ // Mechanik->PutCommand("SetProximityVelocity",scandist,vmechmax,sl);
|
||||
#if LOGBACKSCAN
|
||||
@@ -4944,7 +4950,7 @@ TCommandType TController::BackwardScan()
|
||||
}
|
||||
if ((vmechmax != 0.0) && (scandist < 100.0))
|
||||
{ // jeśli Tm w odległości do 100m podaje zezwolenie na jazdę, to od
|
||||
// razu ją ignorujemy, aby móc szukać kolejnej
|
||||
// razu ją ignorujemy, aby móc szukać kolejnej
|
||||
// eSignSkip=e; //wtedy uznajemy ignorowaną przy poszukiwaniu nowej
|
||||
#if LOGBACKSCAN
|
||||
WriteLog(edir + "- will be ignored due to Ms2");
|
||||
@@ -5054,15 +5060,30 @@ void TController::DirectionForward(bool forward)
|
||||
mvControlling->IncMainCtrl(1); //żeby nie zgasł
|
||||
};
|
||||
|
||||
AnsiString TController::Relation() { return TrainParams->ShowRelation(); }; // zwraca relację pociągu
|
||||
AnsiString TController::Relation()
|
||||
{ // zwraca relację pociągu
|
||||
return TrainParams->ShowRelation();
|
||||
};
|
||||
|
||||
AnsiString TController::TrainName() { return TrainParams->TrainName; }; // zwraca relację pociągu
|
||||
AnsiString TController::TrainName()
|
||||
{ // zwraca relację pociągu
|
||||
return TrainParams->TrainName;
|
||||
};
|
||||
|
||||
int TController::StationCount() { return TrainParams->StationCount; }; // zwraca ilość stacji (miejsc zatrzymania)
|
||||
int TController::StationCount()
|
||||
{ // zwraca ilość stacji (miejsc zatrzymania)
|
||||
return TrainParams->StationCount;
|
||||
};
|
||||
|
||||
int TController::StationIndex() { return TrainParams->StationIndex; }; // zwraca indeks aktualnej stacji (miejsca zatrzymania)
|
||||
int TController::StationIndex()
|
||||
{ // zwraca indeks aktualnej stacji (miejsca zatrzymania)
|
||||
return TrainParams->StationIndex;
|
||||
};
|
||||
|
||||
bool TController::IsStop() { return TrainParams->IsStop(); }; // informuje, czy jest zatrzymanie na najbliższej stacji
|
||||
bool TController::IsStop()
|
||||
{ // informuje, czy jest zatrzymanie na najbliższej stacji
|
||||
return TrainParams->IsStop();
|
||||
};
|
||||
|
||||
void TController::MoveTo(TDynamicObject *to)
|
||||
{ // przesunięcie AI do innego pojazdu (przy zmianie kabiny)
|
||||
|
||||
18
Driver.h
18
Driver.h
@@ -268,7 +268,10 @@ class TController
|
||||
void ControllingSet(); // znajduje człon do sterowania
|
||||
void AutoRewident(); // ustawia hamulce w składzie
|
||||
public:
|
||||
Mtable::TTrainParameters *__fastcall Timetable() { return TrainParams; };
|
||||
Mtable::TTrainParameters *__fastcall Timetable()
|
||||
{
|
||||
return TrainParams;
|
||||
};
|
||||
void PutCommand(AnsiString NewCommand, double NewValue1, double NewValue2,
|
||||
const _mover::TLocation &NewLocation, TStopReason reason = stopComm);
|
||||
bool PutCommand(AnsiString NewCommand, double NewValue1, double NewValue2,
|
||||
@@ -319,8 +322,7 @@ class TController
|
||||
TEvent *__fastcall TableCheckTrackEvent(double fDirection, TTrack *Track);
|
||||
void TableTraceRoute(double fDistance, TDynamicObject *pVehicle = NULL);
|
||||
void TableCheck(double fDistance);
|
||||
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext,
|
||||
double &fAcc);
|
||||
TCommandType TableUpdate(double &fVelDes, double &fDist, double &fNext, double &fAcc);
|
||||
void TablePurger();
|
||||
|
||||
private: // Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu
|
||||
@@ -342,8 +344,14 @@ class TController
|
||||
int StationCount();
|
||||
int StationIndex();
|
||||
bool IsStop();
|
||||
bool Primary() { return this ? bool(iDrivigFlags & movePrimary) : false; };
|
||||
int inline DrivigFlags() { return iDrivigFlags; };
|
||||
bool Primary()
|
||||
{
|
||||
return this ? bool(iDrivigFlags & movePrimary) : false;
|
||||
};
|
||||
int inline DrivigFlags()
|
||||
{
|
||||
return iDrivigFlags;
|
||||
};
|
||||
void MoveTo(TDynamicObject *to);
|
||||
void DirectionInitial();
|
||||
AnsiString TableText(int i);
|
||||
|
||||
22
DynObj.cpp
22
DynObj.cpp
@@ -131,7 +131,8 @@ TAnim::~TAnim()
|
||||
break;
|
||||
}
|
||||
};
|
||||
void TAnim::Parovoz(){// animowanie tłoka i rozrządu parowozu
|
||||
void TAnim::Parovoz(){
|
||||
// animowanie tłoka i rozrządu parowozu
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
TDynamicObject *__fastcall TDynamicObject::FirstFind(int &coupler_nr)
|
||||
@@ -288,7 +289,10 @@ TDynamicObject* TDynamicObject::GetFirstCabDynamic(int cpl_type)
|
||||
};
|
||||
*/
|
||||
|
||||
void TDynamicObject::ABuSetModelShake(vector3 mShake) { modelShake = mShake; };
|
||||
void TDynamicObject::ABuSetModelShake(vector3 mShake)
|
||||
{
|
||||
modelShake = mShake;
|
||||
};
|
||||
|
||||
int TDynamicObject::GetPneumatic(bool front, bool red)
|
||||
{
|
||||
@@ -926,7 +930,7 @@ TDynamicObject *__fastcall TDynamicObject::ABuFindNearestObject(TTrack *Track,
|
||||
{ // wektor [kamera-sprzeg0], potem [kamera-sprzeg1]
|
||||
// Powinno byc wyliczone, ale nie zaszkodzi drugi raz:
|
||||
//(bo co, jesli nie wykonuje sie obrotow wozkow?) - Ra: ale zawsze są liczone
|
||||
//współrzędne sprzęgów
|
||||
// współrzędne sprzęgów
|
||||
// Track->Dynamics[i]->modelRot.z=ABuAcos(Track->Dynamics[i]->Axle0.pPosition-Track->Dynamics[i]->Axle1.pPosition);
|
||||
// poz=Track->Dynamics[i]->vPosition; //pozycja środka pojazdu
|
||||
// kon=vector3( //położenie przodu względem środka
|
||||
@@ -2009,10 +2013,10 @@ void TDynamicObject::Move(double fDistance)
|
||||
bEnabled &= Axle1.Move(fDistance, iAxleFirst); // oś z tyłu pojazdu prusza się pierwsza
|
||||
bEnabled &= Axle0.Move(fDistance /*-fAdjustment*/, !iAxleFirst); // oś z przodu pojazdu
|
||||
}
|
||||
else //gf: bez wywolania Move na postoju nie ma event0
|
||||
else // gf: bez wywolania Move na postoju nie ma event0
|
||||
{
|
||||
bEnabled&=Axle1.Move(fDistance,iAxleFirst); //oś z tyłu pojazdu prusza się pierwsza
|
||||
bEnabled&=Axle0.Move(fDistance,!iAxleFirst); //oś z przodu pojazdu
|
||||
bEnabled &= Axle1.Move(fDistance, iAxleFirst); // oś z tyłu pojazdu prusza się pierwsza
|
||||
bEnabled &= Axle0.Move(fDistance, !iAxleFirst); // oś z przodu pojazdu
|
||||
}
|
||||
if (fDistance != 0.0) // nie liczyć ponownie, jeśli stoi
|
||||
{ // liczenie pozycji pojazdu tutaj, bo jest używane w wielu miejscach
|
||||
@@ -2339,8 +2343,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
if (MoverParameters->PantPress < (MoverParameters->TrainType == dt_EZT ? 2.4 : 3.5))
|
||||
{ // 3.5 wg http://www.transportszynowy.pl/eu06-07pneumat.php
|
||||
//"Wyłączniki ciśnieniowe odbieraków prądu wyłączają sterowanie wyłącznika szybkiego
|
||||
//oraz uniemożliwiają podniesienie odbieraków prądu, gdy w instalacji rozrządu
|
||||
//ciśnienie spadnie poniżej wartości 3,5 bara."
|
||||
// oraz uniemożliwiają podniesienie odbieraków prądu, gdy w instalacji rozrządu
|
||||
// ciśnienie spadnie poniżej wartości 3,5 bara."
|
||||
// Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5
|
||||
// if (!MoverParameters->PantCompFlag)
|
||||
// MoverParameters->PantVolume=MoverParameters->CompressedVolume;
|
||||
@@ -4282,7 +4286,7 @@ void TDynamicObject::LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
|
||||
if (pants[i].fParamPants->vPos.y == 0.0)
|
||||
{ // jeśli pierwsze ramię nie ustawiło tej wartości, próbować drugim
|
||||
//!!!! docelowo zrobić niezależną animację ramion z każdej
|
||||
//strony
|
||||
// strony
|
||||
m = float4x4(
|
||||
*sm->GetMatrix()); // skopiowanie, bo będziemy mnożyć
|
||||
m(3)[1] =
|
||||
|
||||
63
DynObj.h
63
DynObj.h
@@ -338,14 +338,26 @@ class TDynamicObject
|
||||
TDynamicObject *__fastcall Next();
|
||||
TDynamicObject *__fastcall NextC(int C);
|
||||
double NextDistance(double d = -1.0);
|
||||
void SetdMoveLen(double dMoveLen) { MoverParameters->dMoveLen = dMoveLen; }
|
||||
void ResetdMoveLen() { MoverParameters->dMoveLen = 0; }
|
||||
double GetdMoveLen() { return MoverParameters->dMoveLen; }
|
||||
void SetdMoveLen(double dMoveLen)
|
||||
{
|
||||
MoverParameters->dMoveLen = dMoveLen;
|
||||
}
|
||||
void ResetdMoveLen()
|
||||
{
|
||||
MoverParameters->dMoveLen = 0;
|
||||
}
|
||||
double GetdMoveLen()
|
||||
{
|
||||
return MoverParameters->dMoveLen;
|
||||
}
|
||||
|
||||
int GetPneumatic(bool front, bool red);
|
||||
void SetPneumatic(bool front, bool red);
|
||||
AnsiString asName;
|
||||
AnsiString GetName() { return this ? asName : AnsiString(""); };
|
||||
AnsiString GetName()
|
||||
{
|
||||
return this ? asName : AnsiString("");
|
||||
};
|
||||
|
||||
TRealSound rsDiesielInc; // youBy
|
||||
TRealSound rscurve; // youBy
|
||||
@@ -395,7 +407,10 @@ class TDynamicObject
|
||||
void Render();
|
||||
void RenderAlpha();
|
||||
void RenderSounds();
|
||||
inline vector3 GetPosition() { return vPosition; };
|
||||
inline vector3 GetPosition()
|
||||
{
|
||||
return vPosition;
|
||||
};
|
||||
inline vector3 HeadPosition()
|
||||
{
|
||||
return vCoulpler[iDirection ^ 1];
|
||||
@@ -408,13 +423,34 @@ class TDynamicObject
|
||||
{
|
||||
return iAxleFirst ? Axle1.pPosition : Axle0.pPosition;
|
||||
};
|
||||
inline vector3 VectorFront() { return vFront; };
|
||||
inline vector3 VectorUp() { return vUp; };
|
||||
inline vector3 VectorLeft() { return vLeft; };
|
||||
inline double *__fastcall Matrix() { return mMatrix.getArray(); };
|
||||
inline double GetVelocity() { return MoverParameters->Vel; };
|
||||
inline double GetLength() { return MoverParameters->Dim.L; };
|
||||
inline double GetWidth() { return MoverParameters->Dim.W; };
|
||||
inline vector3 VectorFront()
|
||||
{
|
||||
return vFront;
|
||||
};
|
||||
inline vector3 VectorUp()
|
||||
{
|
||||
return vUp;
|
||||
};
|
||||
inline vector3 VectorLeft()
|
||||
{
|
||||
return vLeft;
|
||||
};
|
||||
inline double *__fastcall Matrix()
|
||||
{
|
||||
return mMatrix.getArray();
|
||||
};
|
||||
inline double GetVelocity()
|
||||
{
|
||||
return MoverParameters->Vel;
|
||||
};
|
||||
inline double GetLength()
|
||||
{
|
||||
return MoverParameters->Dim.L;
|
||||
};
|
||||
inline double GetWidth()
|
||||
{
|
||||
return MoverParameters->Dim.W;
|
||||
};
|
||||
inline TTrack *__fastcall GetTrack()
|
||||
{
|
||||
return (iAxleFirst ? Axle1.GetTrack() : Axle0.GetTrack());
|
||||
@@ -422,8 +458,7 @@ class TDynamicObject
|
||||
// void UpdatePos();
|
||||
|
||||
// McZapkie-260202
|
||||
void LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName,
|
||||
AnsiString ReplacableSkin);
|
||||
void LoadMMediaFile(AnsiString BaseDir, AnsiString TypeName, AnsiString ReplacableSkin);
|
||||
|
||||
inline double ABuGetDirection() // ABu.
|
||||
{
|
||||
|
||||
26
EU07.bpr
26
EU07.bpr
@@ -13,13 +13,13 @@
|
||||
TractionPower.obj parser.obj sky.obj AirCoupler.obj opengl\glew.obj
|
||||
ResourceManager.obj VBO.obj TextureDDS.obj opengl\ARB_Multisample.obj
|
||||
Float3d.obj Classes.obj Driver.obj Names.obj Console.obj Mover.obj
|
||||
Console\PoKeys55.obj Forth.obj Console\LPT.obj"/>
|
||||
Console\PoKeys55.obj Forth.obj Console\LPT.obj PyInt.obj"/>
|
||||
<RESFILES value="EU07.res"/>
|
||||
<IDLFILES value=""/>
|
||||
<IDLGENFILES value=""/>
|
||||
<DEFFILE value=""/>
|
||||
<RESDEPEN value="$(RESFILES)"/>
|
||||
<LIBFILES value="opengl\glut32.lib DirectX\Dsound.lib"/>
|
||||
<LIBFILES value="opengl\glut32.lib omf_python27.lib DirectX\Dsound.lib"/>
|
||||
<LIBRARIES value="dclocx50.bpi bcbsmp50.bpi VCLX50.lib bcbsmp50.lib Vcl50.lib"/>
|
||||
<SPARELIBS value="Vcl50.lib bcbsmp50.lib VCLX50.lib bcbsmp50.bpi dclocx50.bpi"/>
|
||||
<PACKAGES value="Vcl50.bpi Vclx50.bpi"/>
|
||||
@@ -33,8 +33,8 @@
|
||||
<USERDEFINES value="GLEW_STATIC;_DEBUG"/>
|
||||
<SYSDEFINES value="NO_STRICT;_RTLDLL"/>
|
||||
<MAINSOURCE value="EU07.cpp"/>
|
||||
<INCLUDEPATH value="Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl"/>
|
||||
<LIBPATH value="Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib"/>
|
||||
<INCLUDEPATH value="Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl;python\include"/>
|
||||
<LIBPATH value="Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib;python\libs"/>
|
||||
<WARNINGS value="-w-par"/>
|
||||
</MACROS>
|
||||
<OPTIONS>
|
||||
@@ -58,8 +58,8 @@ IncludeVerInfo=1
|
||||
AutoIncBuild=0
|
||||
MajorVer=15
|
||||
MinorVer=3
|
||||
Release=1167
|
||||
Build=470
|
||||
Release=1168
|
||||
Build=471
|
||||
Debug=1
|
||||
PreRelease=0
|
||||
Special=0
|
||||
@@ -71,8 +71,8 @@ CodePage=1250
|
||||
[Version Info Keys]
|
||||
CompanyName=EU07 Team
|
||||
FileDescription=MaSzyna EU07-424
|
||||
FileVersion=15.3.1167.470
|
||||
InternalName=9th by firleju + SPKS + MP
|
||||
FileVersion=15.3.1168.471
|
||||
InternalName=9th by firleju + SPKS + MP + python
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=eu07.exe
|
||||
@@ -81,12 +81,14 @@ ProductVersion=15.3
|
||||
Comments=
|
||||
|
||||
[HistoryLists\hlIncludePath]
|
||||
Count=1
|
||||
Item0=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl
|
||||
Count=2
|
||||
Item0=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl;python\include
|
||||
Item1=Console;opengl;McZapkie;$(BCB)\include;$(BCB)\include\vcl
|
||||
|
||||
[HistoryLists\hlLibraryPath]
|
||||
Count=1
|
||||
Item0=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib
|
||||
Count=2
|
||||
Item0=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib;python\libs
|
||||
Item1=Console;opengl;McZapkie;$(BCB)\lib\obj;$(BCB)\lib
|
||||
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=2
|
||||
|
||||
5
EU07.cpp
5
EU07.cpp
@@ -33,6 +33,7 @@ USEUNIT("Camera.cpp");
|
||||
USEUNIT("Texture.cpp");
|
||||
USEUNIT("World.cpp");
|
||||
USELIB("opengl\glut32.lib");
|
||||
USELIB("omf_python27.lib");
|
||||
USEUNIT("Model3d.cpp");
|
||||
USEUNIT("MdlMngr.cpp");
|
||||
USEUNIT("Train.cpp");
|
||||
@@ -80,6 +81,7 @@ USEUNIT("McZapkie\hamulce.pas");
|
||||
USEUNIT("Console\PoKeys55.cpp");
|
||||
USEUNIT("Forth.cpp");
|
||||
USEUNIT("Console\LPT.cpp");
|
||||
USEUNIT("PyInt.cpp");
|
||||
//---------------------------------------------------------------------------
|
||||
#include "World.h"
|
||||
|
||||
@@ -754,6 +756,3 @@ int WINAPI WinMain(HINSTANCE hInstance, // instance
|
||||
KillGLWindow(); // kill the window
|
||||
return (msg.wParam); // exit the program
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,9 +43,14 @@ TEventLauncher::TEventLauncher()
|
||||
iCheckMask = 0;
|
||||
}
|
||||
|
||||
TEventLauncher::~TEventLauncher() { SafeDeleteArray(szText); }
|
||||
TEventLauncher::~TEventLauncher()
|
||||
{
|
||||
SafeDeleteArray(szText);
|
||||
}
|
||||
|
||||
void TEventLauncher::Init() {}
|
||||
void TEventLauncher::Init()
|
||||
{
|
||||
}
|
||||
|
||||
bool TEventLauncher::Load(cParser *parser)
|
||||
{ // wczytanie wyzwalacza zdarzeñ
|
||||
|
||||
@@ -27,9 +27,14 @@ TFadeSound::TFadeSound()
|
||||
fTime = 0;
|
||||
}
|
||||
|
||||
TFadeSound::~TFadeSound() { Free(); }
|
||||
TFadeSound::~TFadeSound()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
void TFadeSound::Free() {}
|
||||
void TFadeSound::Free()
|
||||
{
|
||||
}
|
||||
|
||||
void TFadeSound::Init(char *Name, float fNewFade)
|
||||
{
|
||||
@@ -47,7 +52,10 @@ void TFadeSound::TurnOn()
|
||||
fTime = fFade;
|
||||
}
|
||||
|
||||
void TFadeSound::TurnOff() { State = ss_ShuttingDown; }
|
||||
void TFadeSound::TurnOff()
|
||||
{
|
||||
State = ss_ShuttingDown;
|
||||
}
|
||||
|
||||
void TFadeSound::Update()
|
||||
{
|
||||
|
||||
@@ -26,7 +26,10 @@ class TFadeSound
|
||||
void Init(char *Name, float fNewFade);
|
||||
void TurnOn();
|
||||
void TurnOff();
|
||||
bool Playing() { return (State == ss_Commencing || State == ss_Starting); };
|
||||
bool Playing()
|
||||
{
|
||||
return (State == ss_Commencing || State == ss_Starting);
|
||||
};
|
||||
void Free();
|
||||
void Update();
|
||||
void Volume(long vol);
|
||||
|
||||
45
Float3d.h
45
Float3d.h
@@ -37,7 +37,10 @@ inline float3 &operator+=(float3 &v1, const float3 &v2)
|
||||
v1.z += v2.z;
|
||||
return v1;
|
||||
};
|
||||
inline float3 operator-(const float3 &v) { return float3(-v.x, -v.y, -v.z); };
|
||||
inline float3 operator-(const float3 &v)
|
||||
{
|
||||
return float3(-v.x, -v.y, -v.z);
|
||||
};
|
||||
inline float3 operator-(const float3 &v1, const float3 &v2)
|
||||
{
|
||||
return float3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
|
||||
@@ -46,8 +49,14 @@ inline float3 operator+(const float3 &v1, const float3 &v2)
|
||||
{
|
||||
return float3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
|
||||
};
|
||||
double inline float3::Length() const { return sqrt(x * x + y * y + z * z); };
|
||||
inline float3 operator/(const float3 &v, double k) { return float3(v.x / k, v.y / k, v.z / k); };
|
||||
double inline float3::Length() const
|
||||
{
|
||||
return sqrt(x * x + y * y + z * z);
|
||||
};
|
||||
inline float3 operator/(const float3 &v, double k)
|
||||
{
|
||||
return float3(v.x / k, v.y / k, v.z / k);
|
||||
};
|
||||
inline float3 SafeNormalize(const float3 &v)
|
||||
{ // bezpieczna normalizacja (wektor d³ugoœci 1.0)
|
||||
double l = v.Length();
|
||||
@@ -79,8 +88,14 @@ class float4
|
||||
z = c;
|
||||
w = d;
|
||||
};
|
||||
double inline float4::LengthSquared() const { return x * x + y * y + z * z + w * w; };
|
||||
double inline float4::Length() const { return sqrt(x * x + y * y + z * z + w * w); };
|
||||
double inline float4::LengthSquared() const
|
||||
{
|
||||
return x * x + y * y + z * z + w * w;
|
||||
};
|
||||
double inline float4::Length() const
|
||||
{
|
||||
return sqrt(x * x + y * y + z * z + w * w);
|
||||
};
|
||||
};
|
||||
inline float4 operator*(const float4 &q1, const float4 &q2)
|
||||
{ // mno¿enie to prawie jak mno¿enie macierzy
|
||||
@@ -177,15 +192,24 @@ class float4x4
|
||||
for (int i = 0; i < 16; ++i)
|
||||
e[i] = f[i];
|
||||
};
|
||||
float *__fastcall operator()(int i) { return &e[i << 2]; }
|
||||
const float *__fastcall readArray(void) { return e; }
|
||||
float *__fastcall operator()(int i)
|
||||
{
|
||||
return &e[i << 2];
|
||||
}
|
||||
const float *__fastcall readArray(void)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
void Identity()
|
||||
{
|
||||
for (int i = 0; i < 16; ++i)
|
||||
e[i] = 0;
|
||||
e[0] = e[5] = e[10] = e[15] = 1.0f;
|
||||
}
|
||||
const float *operator[](int i) const { return &e[i << 2]; };
|
||||
const float *operator[](int i) const
|
||||
{
|
||||
return &e[i << 2];
|
||||
};
|
||||
void InitialRotate()
|
||||
{ // taka specjalna rotacja, nie ma co ci¹gaæ trygonometrii
|
||||
float f;
|
||||
@@ -206,7 +230,10 @@ class float4x4
|
||||
return true;
|
||||
}
|
||||
void Quaternion(float4 *q);
|
||||
inline float3 *TranslationGet() { return (float3 *)(e + 12); }
|
||||
inline float3 *TranslationGet()
|
||||
{
|
||||
return (float3 *)(e + 12);
|
||||
}
|
||||
};
|
||||
|
||||
inline float3 operator*(const float4x4 &m, const float3 &v)
|
||||
|
||||
@@ -46,8 +46,8 @@ void TGauge::Clear()
|
||||
fDesiredValue = 0;
|
||||
};
|
||||
|
||||
void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale,
|
||||
double fNewOffset, double fNewFriction, double fNewValue)
|
||||
void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset,
|
||||
double fNewFriction, double fNewValue)
|
||||
{ // ustawienie parametrów animacji submodelu
|
||||
if (NewSubModel)
|
||||
{ // warunek na wszelki wypadek, gdyby siê submodel nie pod³¹czy³
|
||||
|
||||
8
Gauge.h
8
Gauge.h
@@ -50,14 +50,16 @@ class TGauge // zmienne "gg"
|
||||
void Clear();
|
||||
void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1,
|
||||
double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0);
|
||||
bool Load(TQueryParserComp *Parser, TModel3d *md1, TModel3d *md2 = NULL,
|
||||
double mul = 1.0);
|
||||
bool Load(TQueryParserComp *Parser, TModel3d *md1, TModel3d *md2 = NULL, double mul = 1.0);
|
||||
void PermIncValue(double fNewDesired);
|
||||
void IncValue(double fNewDesired);
|
||||
void DecValue(double fNewDesired);
|
||||
void UpdateValue(double fNewDesired);
|
||||
void PutValue(double fNewDesired);
|
||||
float GetValue() { return fValue; };
|
||||
float GetValue()
|
||||
{
|
||||
return fValue;
|
||||
};
|
||||
void Update();
|
||||
void Render();
|
||||
void AssignFloat(float *fValue);
|
||||
|
||||
16
Geom.cpp
16
Geom.cpp
@@ -19,11 +19,17 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Globals.h"
|
||||
#include "Geom.h"
|
||||
|
||||
__fastcall TGeometry::TGeometry() {}
|
||||
__fastcall TGeometry::TGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
__fastcall TGeometry::~TGeometry() {}
|
||||
__fastcall TGeometry::~TGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
bool TGeometry::Init() {}
|
||||
bool TGeometry::Init()
|
||||
{
|
||||
}
|
||||
|
||||
vector3 TGeometry::Load(TQueryParserComp *Parser)
|
||||
{
|
||||
@@ -113,7 +119,9 @@ vector3 TGeometry::Load(TQueryParserComp *Parser)
|
||||
tmp->fSquareRadius += r;
|
||||
}
|
||||
|
||||
bool TGeometry::Render() {}
|
||||
bool TGeometry::Render()
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma package(smart_init)
|
||||
|
||||
@@ -49,9 +49,9 @@ double Global::fLuminance = 1.0; // jasno
|
||||
int Global::iReCompile = 0; // zwiêkszany, gdy trzeba odœwie¿yæ siatki
|
||||
HWND Global::hWnd = NULL; // uchwyt okna
|
||||
int Global::iCameraLast = -1;
|
||||
AnsiString Global::asRelease = "15.3.1167.470";
|
||||
AnsiString Global::asRelease = "15.3.1168.471";
|
||||
AnsiString Global::asVersion =
|
||||
"Compilation 2015-04-14, release " + Global::asRelease + "."; // tutaj, bo wysy³any
|
||||
"Compilation 2015-04-17, release " + Global::asRelease + "."; // tutaj, bo wysy³any
|
||||
int Global::iViewMode = 0; // co aktualnie widaæ: 0-kabina, 1-latanie, 2-sprzêgi, 3-dokumenty
|
||||
int Global::iTextMode = 0; // tryb pracy wyœwietlacza tekstowego
|
||||
int Global::iScreenMode[12] = {0, 0, 0, 0, 0, 0,
|
||||
@@ -465,6 +465,10 @@ void Global::ConfigParse(TQueryParserComp *qp, cParser *cp)
|
||||
asLang = GetNextSymbol(); // domyœlny jêzyk - http://tools.ietf.org/html/bcp47
|
||||
else if (str == AnsiString("opengl")) // deklarowana wersja OpenGL, ¿eby powstrzymaæ b³êdy
|
||||
fOpenGL = GetNextSymbol().ToDouble(); // wymuszenie wersji OpenGL
|
||||
else if (str == AnsiString("pyscreenrendererpriority")) // priority of python screen
|
||||
// renderer
|
||||
TPythonInterpreter::getInstance()->setScreenRendererPriority(
|
||||
GetNextSymbol().LowerCase().c_str());
|
||||
} while (str != "endconfig"); //(!Parser->EndOfFile)
|
||||
// na koniec trochê zale¿noœci
|
||||
if (!bLoadTraction) // wczytywanie drutów i s³upów
|
||||
|
||||
@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "system.hpp"
|
||||
#include "opengl/glew.h"
|
||||
#include "dumb3d.h"
|
||||
#include "PyInt.h"
|
||||
//#include "Classes.h"
|
||||
|
||||
using namespace Math3D;
|
||||
@@ -206,7 +207,10 @@ class Global
|
||||
static AnsiString asHumanCtrlVehicle;
|
||||
static void LoadIniFile(AnsiString asFileName);
|
||||
static void InitKeys(AnsiString asFileName);
|
||||
inline static vector3 GetCameraPosition() { return pCameraPosition; };
|
||||
inline static vector3 GetCameraPosition()
|
||||
{
|
||||
return pCameraPosition;
|
||||
};
|
||||
static void SetCameraPosition(vector3 pNewCameraPosition);
|
||||
static void SetCameraRotation(double Yaw);
|
||||
static int iWriteLogEnabled; // maska bitowa: 1-zapis do pliku, 2-okienko
|
||||
|
||||
19
Ground.cpp
19
Ground.cpp
@@ -1626,8 +1626,7 @@ TGroundNode *__fastcall TGround::AddGroundNode(cParser *parser)
|
||||
*parser >> tmp->hvTraction->NominalVoltage >> tmp->hvTraction->MaxCurrent >>
|
||||
tmp->hvTraction->fResistivity;
|
||||
if (tmp->hvTraction->fResistivity == 0.01) // tyle jest w sceneriach [om/km]
|
||||
tmp->hvTraction->fResistivity =
|
||||
0.075; // taka sensowniejsza wartoϾ za
|
||||
tmp->hvTraction->fResistivity = 0.075; // taka sensowniejsza wartoϾ za
|
||||
// http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf
|
||||
tmp->hvTraction->fResistivity *= 0.001; // teraz [om/m]
|
||||
parser->getTokens();
|
||||
@@ -3202,15 +3201,14 @@ void TGround::InitTracks()
|
||||
Track->asEvent2Name = Current->asName + ":event2";
|
||||
|
||||
if (Track->asEventall0Name.IsEmpty())
|
||||
if (FindEvent(Current->asName+":eventall0"))
|
||||
Track->asEventall0Name=Current->asName+":eventall0";
|
||||
if (FindEvent(Current->asName + ":eventall0"))
|
||||
Track->asEventall0Name = Current->asName + ":eventall0";
|
||||
if (Track->asEventall1Name.IsEmpty())
|
||||
if (FindEvent(Current->asName+":eventall1"))
|
||||
Track->asEventall1Name=Current->asName+":eventall1";
|
||||
if (FindEvent(Current->asName + ":eventall1"))
|
||||
Track->asEventall1Name = Current->asName + ":eventall1";
|
||||
if (Track->asEventall2Name.IsEmpty())
|
||||
if (FindEvent(Current->asName+":eventall2"))
|
||||
Track->asEventall2Name=Current->asName+":eventall2";
|
||||
|
||||
if (FindEvent(Current->asName + ":eventall2"))
|
||||
Track->asEventall2Name = Current->asName + ":eventall2";
|
||||
}
|
||||
Track->AssignEvents(
|
||||
Track->asEvent0Name.IsEmpty() ? NULL : FindEvent(Track->asEvent0Name),
|
||||
@@ -4454,7 +4452,8 @@ bool TGround::GetTraction(TDynamicObject *model)
|
||||
false) // jeœli drut jest ni¿ej ni¿ 15cm pod
|
||||
// œlizgiem
|
||||
{ // prze³¹czamy w tryb po³amania, o ile jedzie;
|
||||
// (bEnableTraction) aby da³o siê jeŸdziæ na koœlawych
|
||||
// (bEnableTraction) aby da³o siê jeŸdziæ na
|
||||
// koœlawych
|
||||
// sceneriach
|
||||
fHorizontal = fabs(DotProduct(vGdzie, vLeft)) -
|
||||
p->fWidth; // i do tego jeszcze
|
||||
|
||||
18
Ground.h
18
Ground.h
@@ -193,8 +193,7 @@ class TSubRect : public Resource, public CMesh
|
||||
TSubRect();
|
||||
virtual ~TSubRect();
|
||||
virtual void Release(); // zwalnianie VBO sektora
|
||||
void NodeAdd(
|
||||
TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory
|
||||
void NodeAdd(TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory
|
||||
void RaNodeAdd(TGroundNode *Node); // dodanie obiektu do listy renderowania
|
||||
void Sort(); // optymalizacja obiektów w sektorze (sortowanie wg tekstur)
|
||||
TTrack *__fastcall FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude);
|
||||
@@ -227,7 +226,10 @@ class TGroundRect : public TSubRect
|
||||
private:
|
||||
int iLastDisplay; // numer klatki w której był ostatnio wyświetlany
|
||||
TSubRect *pSubRects;
|
||||
void Init() { pSubRects = new TSubRect[iNumSubRects * iNumSubRects]; };
|
||||
void Init()
|
||||
{
|
||||
pSubRects = new TSubRect[iNumSubRects * iNumSubRects];
|
||||
};
|
||||
|
||||
public:
|
||||
static int iFrameNumber; // numer kolejny wyświetlanej klatki
|
||||
@@ -359,8 +361,14 @@ class TGround
|
||||
};
|
||||
TSubRect *__fastcall GetSubRect(int iCol, int iRow);
|
||||
TSubRect *__fastcall FastGetSubRect(int iCol, int iRow);
|
||||
int GetRowFromZ(double z) { return (z / fSubRectSize + fHalfTotalNumSubRects); };
|
||||
int GetColFromX(double x) { return (x / fSubRectSize + fHalfTotalNumSubRects); };
|
||||
int GetRowFromZ(double z)
|
||||
{
|
||||
return (z / fSubRectSize + fHalfTotalNumSubRects);
|
||||
};
|
||||
int GetColFromX(double x)
|
||||
{
|
||||
return (x / fSubRectSize + fHalfTotalNumSubRects);
|
||||
};
|
||||
TEvent *__fastcall FindEvent(const AnsiString &asEventName);
|
||||
TEvent *__fastcall FindEventScan(const AnsiString &asEventName);
|
||||
void TrackJoin(TGroundNode *Current);
|
||||
|
||||
24
Machajka.cpp
24
Machajka.cpp
@@ -15,9 +15,14 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Timer.h"
|
||||
#include "Globals.h"
|
||||
|
||||
__fastcall TMachajka::TMachajka() : TTrain() { TTrain::TTrain(); }
|
||||
__fastcall TMachajka::TMachajka() : TTrain()
|
||||
{
|
||||
TTrain::TTrain();
|
||||
}
|
||||
|
||||
__fastcall TMachajka::~TMachajka() {}
|
||||
__fastcall TMachajka::~TMachajka()
|
||||
{
|
||||
}
|
||||
|
||||
bool TMachajka::Init(TDynamicObject *NewDynamicObject)
|
||||
{
|
||||
@@ -63,11 +68,20 @@ void TMachajka::OnKeyPress(int cKey)
|
||||
}
|
||||
}
|
||||
|
||||
bool TMachajka::Update(double dt) { TTrain::Update(dt); }
|
||||
bool TMachajka::Update(double dt)
|
||||
{
|
||||
TTrain::Update(dt);
|
||||
}
|
||||
|
||||
bool TMachajka::UpdateMechPosition() { TTrain::UpdateMechPosition(); }
|
||||
bool TMachajka::UpdateMechPosition()
|
||||
{
|
||||
TTrain::UpdateMechPosition();
|
||||
}
|
||||
|
||||
bool TMachajka::Render() { TTrain::Render(); }
|
||||
bool TMachajka::Render()
|
||||
{
|
||||
TTrain::Render();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma package(smart_init)
|
||||
|
||||
@@ -57,7 +57,10 @@ __fastcall TModelsManager::~TModelsManager()
|
||||
Free();
|
||||
};
|
||||
*/
|
||||
void TModelsManager::Free() { SafeDeleteArray(Models); }
|
||||
void TModelsManager::Free()
|
||||
{
|
||||
SafeDeleteArray(Models);
|
||||
}
|
||||
|
||||
TModel3d *__fastcall TModelsManager::LoadModel(char *Name, bool dynamic)
|
||||
{ // wczytanie modelu do tablicy
|
||||
|
||||
20
MemCell.cpp
20
MemCell.cpp
@@ -41,12 +41,16 @@ TMemCell::TMemCell(vector3 *p)
|
||||
OnSent = NULL;
|
||||
}
|
||||
|
||||
TMemCell::~TMemCell() { SafeDeleteArray(szText); }
|
||||
TMemCell::~TMemCell()
|
||||
{
|
||||
SafeDeleteArray(szText);
|
||||
}
|
||||
|
||||
void TMemCell::Init() {}
|
||||
void TMemCell::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void TMemCell::UpdateValues(char *szNewText, double fNewValue1, double fNewValue2,
|
||||
int CheckMask)
|
||||
void TMemCell::UpdateValues(char *szNewText, double fNewValue1, double fNewValue2, int CheckMask)
|
||||
{
|
||||
if (CheckMask & update_memadd)
|
||||
{ // dodawanie wartoœci
|
||||
@@ -140,8 +144,7 @@ void TMemCell::PutCommand(TController *Mech, vector3 *Loc)
|
||||
Mech->PutCommand(szText, fValue1, fValue2, Loc);
|
||||
}
|
||||
|
||||
bool TMemCell::Compare(char *szTestText, double fTestValue1, double fTestValue2,
|
||||
int CheckMask)
|
||||
bool TMemCell::Compare(char *szTestText, double fTestValue1, double fTestValue2, int CheckMask)
|
||||
{ // porównanie zawartoœci komórki pamiêci z podanymi wartoœciami
|
||||
if (TestFlag(CheckMask, conditional_memstring))
|
||||
{ // porównaæ teksty
|
||||
@@ -161,7 +164,10 @@ bool TMemCell::Compare(char *szTestText, double fTestValue1, double fTestValue2,
|
||||
(!TestFlag(CheckMask, conditional_memval2) || (fValue2 == fTestValue2)));
|
||||
};
|
||||
|
||||
bool TMemCell::Render() { return true; }
|
||||
bool TMemCell::Render()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMemCell::IsVelocity()
|
||||
{ // sprawdzenie, czy event odczytu tej komórki ma byæ do skanowania, czy do kolejkowania
|
||||
|
||||
36
MemCell.h
36
MemCell.h
@@ -30,19 +30,35 @@ class TMemCell
|
||||
TMemCell(vector3 *p);
|
||||
~TMemCell();
|
||||
void Init();
|
||||
void UpdateValues(char *szNewText, double fNewValue1, double fNewValue2,
|
||||
int CheckMask);
|
||||
void UpdateValues(char *szNewText, double fNewValue1, double fNewValue2, int CheckMask);
|
||||
bool Load(cParser *parser);
|
||||
void PutCommand(TController *Mech, vector3 *Loc);
|
||||
bool Compare(char *szTestText, double fTestValue1, double fTestValue2,
|
||||
int CheckMask);
|
||||
bool Compare(char *szTestText, double fTestValue1, double fTestValue2, int CheckMask);
|
||||
bool Render();
|
||||
inline char *__fastcall Text() { return szText; };
|
||||
inline double Value1() { return fValue1; };
|
||||
inline double Value2() { return fValue2; };
|
||||
inline vector3 Position() { return vPosition; };
|
||||
inline TCommandType Command() { return eCommand; };
|
||||
inline bool StopCommand() { return bCommand; };
|
||||
inline char *__fastcall Text()
|
||||
{
|
||||
return szText;
|
||||
};
|
||||
inline double Value1()
|
||||
{
|
||||
return fValue1;
|
||||
};
|
||||
inline double Value2()
|
||||
{
|
||||
return fValue2;
|
||||
};
|
||||
inline vector3 Position()
|
||||
{
|
||||
return vPosition;
|
||||
};
|
||||
inline TCommandType Command()
|
||||
{
|
||||
return eCommand;
|
||||
};
|
||||
inline bool StopCommand()
|
||||
{
|
||||
return bCommand;
|
||||
};
|
||||
void StopCommandSent();
|
||||
TCommandType CommandCheck();
|
||||
bool IsVelocity();
|
||||
|
||||
30
Model3d.cpp
30
Model3d.cpp
@@ -178,8 +178,7 @@ void TSubModel::NameSet(const char *n)
|
||||
|
||||
// int TSubModel::SeekFaceNormal(DWORD *Masks, int f,DWORD dwMask,vector3 *pt,GLVERTEX
|
||||
// *Vertices)
|
||||
int TSubModel::SeekFaceNormal(DWORD *Masks, int f, DWORD dwMask, float3 *pt,
|
||||
float8 *Vertices)
|
||||
int TSubModel::SeekFaceNormal(DWORD *Masks, int f, DWORD dwMask, float3 *pt, float8 *Vertices)
|
||||
{ // szukanie punktu stycznego do (pt), zwraca numer wierzcho³ka, a nie trójk¹ta
|
||||
int iNumFaces = iNumVerts / 3; // bo maska powierzchni jest jedna na trójk¹t
|
||||
// GLVERTEX *p; //roboczy wskaŸnik
|
||||
@@ -916,7 +915,10 @@ void TSubModel::SetRotateIK1(float3 vNewAngles)
|
||||
|
||||
struct ToLower
|
||||
{
|
||||
char operator()(char input) { return tolower(input); }
|
||||
char operator()(char input)
|
||||
{
|
||||
return tolower(input);
|
||||
}
|
||||
};
|
||||
|
||||
TSubModel *__fastcall TSubModel::GetFromName(AnsiString search, bool i)
|
||||
@@ -1523,8 +1525,8 @@ void TSubModel::InfoSet(TSubModelInfo *info)
|
||||
pTexture = pName = NULL;
|
||||
};
|
||||
|
||||
void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t,
|
||||
TStringPack *n, bool dynamic)
|
||||
void TSubModel::BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TStringPack *n,
|
||||
bool dynamic)
|
||||
{ // ustawienie wskaŸników w submodelu
|
||||
iVisible = 1; // tymczasowo u¿ywane
|
||||
Child = ((int)Child > 0) ? s + (int)Child : NULL; // zerowy nie mo¿e byæ potomnym
|
||||
@@ -2019,7 +2021,10 @@ void TModel3d::SaveToBinFile(char *FileName)
|
||||
delete[] info;
|
||||
};
|
||||
|
||||
void TModel3d::BreakHierarhy() { Error("Not implemented yet :("); };
|
||||
void TModel3d::BreakHierarhy()
|
||||
{
|
||||
Error("Not implemented yet :(");
|
||||
};
|
||||
|
||||
/*
|
||||
void TModel3d::Render(vector3 pPosition,double fAngle,GLuint ReplacableSkinId,int iAlpha)
|
||||
@@ -2122,8 +2127,7 @@ void TModel3d::RaRender(double fSquareDistance, GLuint *ReplacableSkinId, int iA
|
||||
}
|
||||
};
|
||||
|
||||
void TModel3d::RaRenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId,
|
||||
int iAlpha)
|
||||
void TModel3d::RaRenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId, int iAlpha)
|
||||
{ // renderowanie specjalne, np. kabiny
|
||||
if (iAlpha & iFlags & 0x2F2F002F) // czy w ogóle jest co robiæ w tym cyklu?
|
||||
{
|
||||
@@ -2159,8 +2163,7 @@ iAlpha)
|
||||
// 2011-03-16 cztery nowe funkcje renderowania z mo¿liwoœci¹ pochylania obiektów
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void TModel3d::Render(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId,
|
||||
int iAlpha)
|
||||
void TModel3d::Render(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId, int iAlpha)
|
||||
{ // nieprzezroczyste, Display List
|
||||
glPushMatrix();
|
||||
glTranslated(vPosition->x, vPosition->y, vPosition->z);
|
||||
@@ -2194,8 +2197,7 @@ void TModel3d::RenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *Replacab
|
||||
Root->RenderAlphaDL();
|
||||
glPopMatrix();
|
||||
};
|
||||
void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId,
|
||||
int iAlpha)
|
||||
void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId, int iAlpha)
|
||||
{ // nieprzezroczyste, VBO
|
||||
glPushMatrix();
|
||||
glTranslated(vPosition->x, vPosition->y, vPosition->z);
|
||||
@@ -2215,8 +2217,8 @@ void TModel3d::RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableS
|
||||
}
|
||||
glPopMatrix();
|
||||
};
|
||||
void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle,
|
||||
GLuint *ReplacableSkinId, int iAlpha)
|
||||
void TModel3d::RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId,
|
||||
int iAlpha)
|
||||
{ // przezroczyste, VBO
|
||||
glPushMatrix();
|
||||
glTranslated(vPosition->x, vPosition->y, vPosition->z);
|
||||
|
||||
95
Model3d.h
95
Model3d.h
@@ -36,21 +36,33 @@ class TStringPack
|
||||
//+8 - tabela indeksów
|
||||
public:
|
||||
char *String(int n);
|
||||
char *StringAt(int n) { return data + 9 + n; };
|
||||
char *StringAt(int n)
|
||||
{
|
||||
return data + 9 + n;
|
||||
};
|
||||
TStringPack()
|
||||
{
|
||||
data = NULL;
|
||||
index = NULL;
|
||||
};
|
||||
void Init(char *d) { data = d; };
|
||||
void InitIndex(int *i) { index = i; };
|
||||
void Init(char *d)
|
||||
{
|
||||
data = d;
|
||||
};
|
||||
void InitIndex(int *i)
|
||||
{
|
||||
index = i;
|
||||
};
|
||||
};
|
||||
|
||||
class TMaterialColor
|
||||
{
|
||||
public:
|
||||
TMaterialColor(){};
|
||||
TMaterialColor(char V) { r = g = b = V; };
|
||||
TMaterialColor(char V)
|
||||
{
|
||||
r = g = b = V;
|
||||
};
|
||||
// TMaterialColor(double R, double G, double B)
|
||||
TMaterialColor(char R, char G, char B)
|
||||
{
|
||||
@@ -250,8 +262,14 @@ class TSubModel
|
||||
int Load(cParser &Parser, TModel3d *Model, int Pos, bool dynamic);
|
||||
void ChildAdd(TSubModel *SubModel);
|
||||
void NextAdd(TSubModel *SubModel);
|
||||
TSubModel *__fastcall NextGet() { return Next; };
|
||||
TSubModel *__fastcall ChildGet() { return Child; };
|
||||
TSubModel *__fastcall NextGet()
|
||||
{
|
||||
return Next;
|
||||
};
|
||||
TSubModel *__fastcall ChildGet()
|
||||
{
|
||||
return Child;
|
||||
};
|
||||
int TriangleAdd(TModel3d *m, int tex, int tri);
|
||||
float8 *__fastcall TrianglePtr(int tex, int pos, int *la, int *ld, int *ls);
|
||||
// float8* TrianglePtr(const char *tex,int tri);
|
||||
@@ -269,9 +287,15 @@ class TSubModel
|
||||
void RenderVBO();
|
||||
void RenderAlphaVBO();
|
||||
// inline matrix4x4* GetMatrix() {return dMatrix;};
|
||||
inline float4x4 *__fastcall GetMatrix() { return fMatrix; };
|
||||
inline float4x4 *__fastcall GetMatrix()
|
||||
{
|
||||
return fMatrix;
|
||||
};
|
||||
// matrix4x4* GetTransform() {return Matrix;};
|
||||
inline void Hide() { iVisible = 0; };
|
||||
inline void Hide()
|
||||
{
|
||||
iVisible = 0;
|
||||
};
|
||||
void RaArrayFill(CVertNormTex *Vert);
|
||||
// void Render();
|
||||
int FlagsCheck();
|
||||
@@ -284,8 +308,8 @@ class TSubModel
|
||||
void DisplayLists();
|
||||
void Info();
|
||||
void InfoSet(TSubModelInfo *info);
|
||||
void BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t,
|
||||
TStringPack *n = NULL, bool dynamic = false);
|
||||
void BinInit(TSubModel *s, float4x4 *m, float8 *v, TStringPack *t, TStringPack *n = NULL,
|
||||
bool dynamic = false);
|
||||
void ReplacableSet(GLuint *r, int a)
|
||||
{
|
||||
ReplacableSkinId = r;
|
||||
@@ -294,8 +318,14 @@ class TSubModel
|
||||
void TextureNameSet(const char *n);
|
||||
void NameSet(const char *n);
|
||||
// Ra: funkcje do budowania terenu z E3D
|
||||
int Flags() { return iFlags; };
|
||||
void UnFlagNext() { iFlags &= 0x00FFFFFF; };
|
||||
int Flags()
|
||||
{
|
||||
return iFlags;
|
||||
};
|
||||
void UnFlagNext()
|
||||
{
|
||||
iFlags &= 0x00FFFFFF;
|
||||
};
|
||||
void ColorsSet(int *a, int *d, int *s);
|
||||
inline float3 Translation1Get()
|
||||
{
|
||||
@@ -305,6 +335,10 @@ class TSubModel
|
||||
{
|
||||
return *(fMatrix->TranslationGet()) + Child->Translation1Get();
|
||||
}
|
||||
int GetTextureId()
|
||||
{
|
||||
return TextureID;
|
||||
}
|
||||
void ParentMatrix(float4x4 *m);
|
||||
float MaxY(const float4x4 &m);
|
||||
void AdjustDist();
|
||||
@@ -356,7 +390,10 @@ class TModel3d : public CMesh
|
||||
int iSubModelsCount; // Ra: używane do tworzenia binarnych
|
||||
AnsiString asBinary; // nazwa pod którą zapisać model binarny
|
||||
public:
|
||||
inline TSubModel *__fastcall GetSMRoot() { return (Root); };
|
||||
inline TSubModel *__fastcall GetSMRoot()
|
||||
{
|
||||
return (Root);
|
||||
};
|
||||
// double Radius; //Ra: nie używane
|
||||
TModel3d();
|
||||
TModel3d(char *FileName);
|
||||
@@ -371,36 +408,40 @@ class TModel3d : public CMesh
|
||||
void SaveToBinFile(char *FileName);
|
||||
void BreakHierarhy();
|
||||
// renderowanie specjalne
|
||||
void Render(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void Render(double fSquareDistance, GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
|
||||
void RenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RaRender(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RaRender(double fSquareDistance, GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
|
||||
void RaRenderAlpha(double fSquareDistance, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
// jeden kąt obrotu
|
||||
void Render(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RenderAlpha(vector3 pPosition, double fAngle = 0,
|
||||
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
|
||||
void RenderAlpha(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RaRender(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RaRenderAlpha(vector3 pPosition, double fAngle = 0,
|
||||
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
|
||||
void RaRenderAlpha(vector3 pPosition, double fAngle = 0, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
// trzy kąty obrotu
|
||||
void Render(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RenderAlpha(vector3 *vPosition, vector3 *vAngle,
|
||||
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
|
||||
void RenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RaRender(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
void RaRenderAlpha(vector3 *vPosition, vector3 *vAngle,
|
||||
GLuint *ReplacableSkinId = NULL, int iAlpha = 0x30300030);
|
||||
void RaRenderAlpha(vector3 *vPosition, vector3 *vAngle, GLuint *ReplacableSkinId = NULL,
|
||||
int iAlpha = 0x30300030);
|
||||
// inline int GetSubModelsCount() { return (SubModelsCount); };
|
||||
int Flags() { return iFlags; };
|
||||
int Flags()
|
||||
{
|
||||
return iFlags;
|
||||
};
|
||||
void Init();
|
||||
char *__fastcall NameGet() { return Root ? Root->pName : NULL; };
|
||||
char *__fastcall NameGet()
|
||||
{
|
||||
return Root ? Root->pName : NULL;
|
||||
};
|
||||
int TerrainCount();
|
||||
TSubModel *__fastcall TerrainSquare(int n);
|
||||
void TerrainRenderVBO(int n);
|
||||
|
||||
29
Mover.cpp
29
Mover.cpp
@@ -16,9 +16,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
const dEpsilon = 0.01; // 1cm (zale¿y od typu sprzêgu...)
|
||||
|
||||
TMoverParameters::TMoverParameters(double VelInitial, AnsiString TypeNameInit,
|
||||
AnsiString NameInit, int LoadInitial,
|
||||
AnsiString LoadTypeInitial, int Cab)
|
||||
TMoverParameters::TMoverParameters(double VelInitial, AnsiString TypeNameInit, AnsiString NameInit,
|
||||
int LoadInitial, AnsiString LoadTypeInitial, int Cab)
|
||||
: T_MoverParameters(VelInitial, TypeNameInit, NameInit, LoadInitial, LoadTypeInitial, Cab)
|
||||
{ // g³ówny konstruktor
|
||||
DimHalf.x = 0.5 * Dim.W; // po³owa szerokoœci, OX jest w bok?
|
||||
@@ -37,8 +36,8 @@ double TMoverParameters::Distance(const TLocation &Loc1, const TLocation &Loc2,
|
||||
return hypot(Loc2.X - Loc1.X, Loc1.Y - Loc2.Y) - 0.5 * (Dim2.L + Dim1.L);
|
||||
};
|
||||
|
||||
double TMoverParameters::Distance(const vector3 &s1, const vector3 &s2,
|
||||
const vector3 &d1, const vector3 &d2){
|
||||
double TMoverParameters::Distance(const vector3 &s1, const vector3 &s2, const vector3 &d1,
|
||||
const vector3 &d2){
|
||||
// obliczenie odleg³oœci prostopad³oœcianów o œrodkach (s1) i (s2) i wymiarach (d1) i (d2)
|
||||
// return 0.0; //bêdzie zg³aszaæ warning - funkcja do usuniêcia, chyba ¿e siê przyda...
|
||||
};
|
||||
@@ -50,9 +49,8 @@ double TMoverParameters::CouplerDist(Byte Coupler)
|
||||
Couplers[Coupler].Connected->Dim); // odleg³oœæ pomiêdzy sprzêgami (kula!)
|
||||
};
|
||||
|
||||
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr,
|
||||
TMoverParameters *ConnectTo, Byte CouplingType,
|
||||
bool Forced)
|
||||
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr, TMoverParameters *ConnectTo,
|
||||
Byte CouplingType, bool Forced)
|
||||
{ //³¹czenie do swojego sprzêgu (ConnectNo) pojazdu (ConnectTo) stron¹ (ConnectToNr)
|
||||
// Ra: zwykle wykonywane dwukrotnie, dla ka¿dego pojazdu oddzielnie
|
||||
// Ra: trzeba by odró¿niæ wymóg dociœniêcia od uszkodzenia sprzêgu przy podczepianiu AI do
|
||||
@@ -94,9 +92,8 @@ bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr,
|
||||
// sprzêgu, brak haka
|
||||
};
|
||||
|
||||
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr,
|
||||
T_MoverParameters *ConnectTo, Byte CouplingType,
|
||||
bool Forced)
|
||||
bool TMoverParameters::Attach(Byte ConnectNo, Byte ConnectToNr, T_MoverParameters *ConnectTo,
|
||||
Byte CouplingType, bool Forced)
|
||||
{ //³¹czenie do (ConnectNo) pojazdu (ConnectTo) stron¹ (ConnectToNr)
|
||||
return Attach(ConnectNo, ConnectToNr, (TMoverParameters *)ConnectTo, CouplingType, Forced);
|
||||
};
|
||||
@@ -234,10 +231,13 @@ bool TMoverParameters::BrakeLevelAdd(double b)
|
||||
|
||||
bool TMoverParameters::IncBrakeLevel()
|
||||
{ // nowa wersja na u¿ytek AI, false gdy osi¹gniêto pozycjê BrakeCtrlPosNo
|
||||
return BrakeLevelAdd(1.0); };
|
||||
return BrakeLevelAdd(1.0);
|
||||
};
|
||||
|
||||
bool TMoverParameters::DecBrakeLevel()
|
||||
{ return BrakeLevelAdd(-1.0); }; // nowa wersja na u¿ytek AI, false gdy osi¹gniêto pozycjê -1
|
||||
{ // nowa wersja na u¿ytek AI, false gdy osi¹gniêto pozycjê -1
|
||||
return BrakeLevelAdd(-1.0);
|
||||
};
|
||||
|
||||
bool TMoverParameters::ChangeCab(int direction)
|
||||
{ // zmiana kabiny i resetowanie ustawien
|
||||
@@ -475,8 +475,7 @@ ZN //masa
|
||||
*/
|
||||
|
||||
double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape,
|
||||
TTrackParam &Track,
|
||||
TTractionParam &ElectricTraction,
|
||||
TTrackParam &Track, TTractionParam &ElectricTraction,
|
||||
const TLocation &NewLoc, TRotation &NewRot)
|
||||
{ // trzeba po ma³u przenosiæ tu tê funkcjê
|
||||
double d;
|
||||
|
||||
16
Mover.h
16
Mover.h
@@ -50,10 +50,10 @@ class TMoverParameters : public T_MoverParameters
|
||||
const TDimension &Dim2);
|
||||
double Distance(const vector3 &Loc1, const vector3 &Loc2, const vector3 &Dim1,
|
||||
const vector3 &Dim2);
|
||||
bool Attach(Byte ConnectNo, Byte ConnectToNr, TMoverParameters *ConnectTo,
|
||||
Byte CouplingType, bool Forced = false);
|
||||
bool Attach(Byte ConnectNo, Byte ConnectToNr, T_MoverParameters *ConnectTo,
|
||||
Byte CouplingType, bool Forced = false);
|
||||
bool Attach(Byte ConnectNo, Byte ConnectToNr, TMoverParameters *ConnectTo, Byte CouplingType,
|
||||
bool Forced = false);
|
||||
bool Attach(Byte ConnectNo, Byte ConnectToNr, T_MoverParameters *ConnectTo, Byte CouplingType,
|
||||
bool Forced = false);
|
||||
int DettachStatus(Byte ConnectNo);
|
||||
bool Dettach(Byte ConnectNo);
|
||||
void SetCoupleDist();
|
||||
@@ -65,9 +65,9 @@ class TMoverParameters : public T_MoverParameters
|
||||
bool ChangeCab(int direction);
|
||||
bool CurrentSwitch(int direction);
|
||||
void UpdateBatteryVoltage(double dt);
|
||||
double ComputeMovement(double dt, double dt1, const TTrackShape &Shape,
|
||||
TTrackParam &Track, TTractionParam &ElectricTraction,
|
||||
const TLocation &NewLoc, TRotation &NewRot);
|
||||
double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track,
|
||||
TTractionParam &ElectricTraction, const TLocation &NewLoc,
|
||||
TRotation &NewRot);
|
||||
double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track,
|
||||
const TLocation &NewLoc, TRotation &NewRot);
|
||||
double ShowEngineRotation(int VehN);
|
||||
@@ -170,7 +170,7 @@ class TMoverParameters : public T_MoverParameters
|
||||
// TLocation &NewLoc, TRotation &NewRot);
|
||||
// bool ChangeOffsetH(double DeltaOffset);
|
||||
//__fastcall T_MoverParameters(double VelInitial, AnsiString TypeNameInit, AnsiString NameInit,
|
||||
//int LoadInitial
|
||||
// int LoadInitial
|
||||
// , AnsiString LoadTypeInitial, int Cab);
|
||||
// bool LoadChkFile(AnsiString chkpath);
|
||||
// bool CheckLocomotiveParameters(bool ReadyFlag, int Dir);
|
||||
|
||||
13
Names.h
13
Names.h
@@ -26,8 +26,14 @@ class ItemRecord
|
||||
// typedef
|
||||
void ListGet(ItemRecord *r, int *&n);
|
||||
void TreeAdd(ItemRecord *r, int c);
|
||||
template <typename TOut> inline TOut *DataGet() { return (TOut *)pData; };
|
||||
template <typename TOut> inline void DataSet(TOut *x) { pData = (void *)x; };
|
||||
template <typename TOut> inline TOut *DataGet()
|
||||
{
|
||||
return (TOut *)pData;
|
||||
};
|
||||
template <typename TOut> inline void DataSet(TOut *x)
|
||||
{
|
||||
pData = (void *)x;
|
||||
};
|
||||
void *__fastcall TreeFind(const char *n);
|
||||
ItemRecord *__fastcall TreeFindRecord(const char *n);
|
||||
};
|
||||
@@ -46,8 +52,7 @@ class TNames
|
||||
int Add(int t, const char *n); // dodanie obiektu typu (t)
|
||||
int Add(int t, const char *n, void *d); // dodanie obiektu z wskaŸnikiem
|
||||
int Add(int t, const char *n, int d); // dodanie obiektu z numerem
|
||||
bool Update(int t, const char *n,
|
||||
void *d); // dodanie jeœli nie ma, wymiana (d), gdy jest
|
||||
bool Update(int t, const char *n, void *d); // dodanie jeœli nie ma, wymiana (d), gdy jest
|
||||
void TreeSet();
|
||||
ItemRecord *__fastcall TreeSet(int *n, int d, int u);
|
||||
void Sort(int t); // przebudowa drzewa typu (t)
|
||||
|
||||
601
PyInt.cpp
Normal file
601
PyInt.cpp
Normal file
@@ -0,0 +1,601 @@
|
||||
#include "PyInt.h"
|
||||
#include "Train.h"
|
||||
#include "Logs.h"
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
TPythonInterpreter *TPythonInterpreter::_instance = NULL;
|
||||
|
||||
//#define _PY_INT_MORE_LOG
|
||||
|
||||
TPythonInterpreter::TPythonInterpreter()
|
||||
{
|
||||
WriteLog("Loading Python ...");
|
||||
Py_SetPythonHome("python");
|
||||
Py_Initialize();
|
||||
_main = PyImport_ImportModule("__main__");
|
||||
if (_main == NULL)
|
||||
{
|
||||
WriteLog("Cannot import Python module __main__");
|
||||
}
|
||||
_screenRendererPriority = THREAD_PRIORITY_NORMAL; // domyslny priorytet normalny
|
||||
PyObject *cStringModule = PyImport_ImportModule("cStringIO");
|
||||
_stdErr = NULL;
|
||||
if (cStringModule == NULL)
|
||||
return;
|
||||
PyObject *cStringClassName = PyObject_GetAttrString(cStringModule, "StringIO");
|
||||
if (cStringClassName == NULL)
|
||||
return;
|
||||
PyObject *cString = PyObject_CallObject(cStringClassName, NULL);
|
||||
if (cString == NULL)
|
||||
return;
|
||||
if (PySys_SetObject("stderr", cString) != 0)
|
||||
return;
|
||||
_stdErr = cString;
|
||||
}
|
||||
|
||||
TPythonInterpreter *TPythonInterpreter::getInstance()
|
||||
{
|
||||
if (!_instance)
|
||||
{
|
||||
_instance = new TPythonInterpreter();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
bool TPythonInterpreter::loadClassFile(const char *lookupPath, const char *className)
|
||||
{
|
||||
std::set<const char *, ltstr>::const_iterator it = _classes.find(className);
|
||||
if (it == _classes.end())
|
||||
{
|
||||
FILE *sourceFile = _getFile(lookupPath, className);
|
||||
if (sourceFile != NULL)
|
||||
{
|
||||
fseek(sourceFile, 0, SEEK_END);
|
||||
long fsize = ftell(sourceFile);
|
||||
char *buffer = (char *)calloc(fsize + 1, sizeof(char));
|
||||
fseek(sourceFile, 0, SEEK_SET);
|
||||
long freaded = fread(buffer, sizeof(char), fsize, sourceFile);
|
||||
buffer[freaded] = 0; // z jakiegos powodu czytamy troche mniej i trzczeba dodac konczace
|
||||
// zero do bufora (mimo ze calloc teoretycznie powiniene zwrocic
|
||||
// wyzerowana pamiec)
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
char buf[255];
|
||||
sprintf(buf, "readed %d / %d characters for %s", freaded, fsize, className);
|
||||
WriteLog(buf);
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
fclose(sourceFile);
|
||||
if (PyRun_SimpleString(buffer) != 0)
|
||||
{
|
||||
handleError();
|
||||
return false;
|
||||
}
|
||||
char *classNameToRemember = (char *)calloc(strlen(className) + 1, sizeof(char));
|
||||
strcpy(classNameToRemember, className);
|
||||
_classes.insert(classNameToRemember);
|
||||
free(buffer);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PyObject *TPythonInterpreter::newClass(const char *className)
|
||||
{
|
||||
return newClass(className, NULL);
|
||||
}
|
||||
|
||||
FILE *TPythonInterpreter::_getFile(const char *lookupPath, const char *className)
|
||||
{
|
||||
char *sourceFilePath;
|
||||
if (lookupPath != NULL)
|
||||
{
|
||||
sourceFilePath = (char *)calloc(strlen(lookupPath) + strlen(className) + 4, sizeof(char));
|
||||
strcat(sourceFilePath, lookupPath);
|
||||
strcat(sourceFilePath, className);
|
||||
strcat(sourceFilePath, ".py");
|
||||
|
||||
FILE *file = fopen(sourceFilePath, "r");
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog(sourceFilePath);
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
free(sourceFilePath);
|
||||
if (file != NULL)
|
||||
{
|
||||
return file;
|
||||
}
|
||||
}
|
||||
char *basePath = "python\\local\\";
|
||||
sourceFilePath = (char *)calloc(strlen(basePath) + strlen(className) + 4, sizeof(char));
|
||||
strcat(sourceFilePath, basePath);
|
||||
strcat(sourceFilePath, className);
|
||||
strcat(sourceFilePath, ".py");
|
||||
|
||||
FILE *file = fopen(sourceFilePath, "r");
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog(sourceFilePath);
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
free(sourceFilePath);
|
||||
if (file != NULL)
|
||||
{
|
||||
return file;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TPythonInterpreter::handleError()
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python Error occured");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
if (_stdErr != NULL)
|
||||
{ // std err pythona jest buforowane
|
||||
PyErr_Print();
|
||||
PyObject *bufferContent = PyObject_CallMethod(_stdErr, "getvalue", NULL);
|
||||
PyObject_CallMethod(_stdErr, "truncate", "i", 0); // czyscimy bufor na kolejne bledy
|
||||
WriteLog(PyString_AsString(bufferContent));
|
||||
}
|
||||
else
|
||||
{ // nie dziala buffor pythona
|
||||
if (PyErr_Occurred() != NULL)
|
||||
{
|
||||
PyObject *ptype, *pvalue, *ptraceback;
|
||||
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
|
||||
if (ptype == NULL)
|
||||
{
|
||||
WriteLog("Don't konw how to handle NULL exception");
|
||||
}
|
||||
PyErr_NormalizeException(&ptype, &pvalue, &ptraceback);
|
||||
if (ptype == NULL)
|
||||
{
|
||||
WriteLog("Don't konw how to handle NULL exception");
|
||||
}
|
||||
PyObject *pStrType = PyObject_Str(ptype);
|
||||
if (pStrType != NULL)
|
||||
{
|
||||
WriteLog(PyString_AsString(pStrType));
|
||||
}
|
||||
WriteLog(PyString_AsString(pvalue));
|
||||
PyObject *pStrTraceback = PyObject_Str(ptraceback);
|
||||
if (pStrTraceback != NULL)
|
||||
{
|
||||
WriteLog(PyString_AsString(pStrTraceback));
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog("Python Traceback cannot be shown");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Called python error handler when no error occured!");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
}
|
||||
}
|
||||
PyObject *TPythonInterpreter::newClass(const char *className, PyObject *argsTuple)
|
||||
{
|
||||
if (_main == NULL)
|
||||
{
|
||||
WriteLog("main turned into null");
|
||||
return NULL;
|
||||
}
|
||||
PyObject *classNameObj = PyObject_GetAttrString(_main, className);
|
||||
if (classNameObj == NULL)
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
char buf[255];
|
||||
sprintf(buf, "Python class %s not defined!", className);
|
||||
WriteLog(buf);
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
return NULL;
|
||||
}
|
||||
PyObject *object = PyObject_CallObject(classNameObj, argsTuple);
|
||||
|
||||
if (PyErr_Occurred() != NULL)
|
||||
{
|
||||
handleError();
|
||||
return NULL;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
void TPythonInterpreter::setScreenRendererPriority(const char *priority)
|
||||
{
|
||||
if (strncmp(priority, "normal", 6) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_NORMAL;
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Normal");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
else if (strncmp(priority, "lower", 5) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_BELOW_NORMAL;
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Lower");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
else if (strncmp(priority, "lowest", 6) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_LOWEST;
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Lowest");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
else if (strncmp(priority, "idle", 4) == 0)
|
||||
{
|
||||
_screenRendererPriority = THREAD_PRIORITY_IDLE;
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python screen renderer priority: Idle");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
}
|
||||
|
||||
TPythonScreenRenderer::TPythonScreenRenderer(int textureId, PyObject *renderer)
|
||||
{
|
||||
_textureId = textureId;
|
||||
_pyRenderer = renderer;
|
||||
}
|
||||
|
||||
void TPythonScreenRenderer::updateTexture()
|
||||
{
|
||||
int width, height;
|
||||
if (_pyWidth == NULL || _pyHeight == NULL)
|
||||
{
|
||||
WriteLog("Unknown python texture size!");
|
||||
return;
|
||||
}
|
||||
width = PyInt_AsLong(_pyWidth);
|
||||
height = PyInt_AsLong(_pyHeight);
|
||||
if (_pyTexture != NULL)
|
||||
{
|
||||
char *textureData = PyString_AsString(_pyTexture);
|
||||
if (textureData != NULL)
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
char buff[255];
|
||||
sprintf(buff, "Sending texture id: %d w: %d h: %d", _textureId, width, height);
|
||||
WriteLog(buff);
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glBindTexture(GL_TEXTURE_2D, _textureId);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE,
|
||||
textureData);
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
GLenum status = glGetError();
|
||||
switch (status)
|
||||
{
|
||||
case GL_INVALID_ENUM:
|
||||
WriteLog("An unacceptable value is specified for an enumerated argument. The "
|
||||
"offending function is ignored, having no side effect other than to set "
|
||||
"the error flag.");
|
||||
break;
|
||||
case GL_INVALID_VALUE:
|
||||
WriteLog("A numeric argument is out of range. The offending function is ignored, "
|
||||
"having no side effect other than to set the error flag.");
|
||||
break;
|
||||
case GL_INVALID_OPERATION:
|
||||
WriteLog("The specified operation is not allowed in the current state. The "
|
||||
"offending function is ignored, having no side effect other than to set "
|
||||
"the error flag.");
|
||||
break;
|
||||
case GL_NO_ERROR:
|
||||
WriteLog("No error has been recorded. The value of this symbolic constant is "
|
||||
"guaranteed to be zero.");
|
||||
break;
|
||||
case GL_STACK_OVERFLOW:
|
||||
WriteLog("This function would cause a stack overflow. The offending function is "
|
||||
"ignored, having no side effect other than to set the error flag.");
|
||||
break;
|
||||
case GL_STACK_UNDERFLOW:
|
||||
WriteLog("This function would cause a stack underflow. The offending function is "
|
||||
"ignored, having no side effect other than to set the error flag.");
|
||||
break;
|
||||
case GL_OUT_OF_MEMORY:
|
||||
WriteLog("There is not enough memory left to execute the function. The state of "
|
||||
"OpenGL is undefined, except for the state of the error flags, after this "
|
||||
"error is recorded.");
|
||||
break;
|
||||
};
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog("RAW python texture data is NULL!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLog("Python texture object is NULL!");
|
||||
}
|
||||
}
|
||||
|
||||
void TPythonScreenRenderer::render(PyObject *trainState)
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python rendering texture ...");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
_pyTexture = PyObject_CallMethod(_pyRenderer, "render", "O", trainState);
|
||||
|
||||
if (_pyTexture == NULL)
|
||||
{
|
||||
TPythonInterpreter::getInstance()->handleError();
|
||||
}
|
||||
else
|
||||
{
|
||||
_pyWidth = PyObject_CallMethod(_pyRenderer, "get_width", NULL);
|
||||
if (_pyWidth == NULL)
|
||||
{
|
||||
TPythonInterpreter::getInstance()->handleError();
|
||||
}
|
||||
_pyHeight = PyObject_CallMethod(_pyRenderer, "get_height", NULL);
|
||||
if (_pyHeight == NULL)
|
||||
{
|
||||
TPythonInterpreter::getInstance()->handleError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TPythonScreenRenderer::~TPythonScreenRenderer()
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("PythonScreenRenderer descturctor called");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
if (_pyRenderer != NULL)
|
||||
{
|
||||
Py_CLEAR(_pyRenderer);
|
||||
}
|
||||
cleanup();
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("PythonScreenRenderer desctructor finished");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
}
|
||||
|
||||
void TPythonScreenRenderer::cleanup()
|
||||
{
|
||||
if (_pyTexture != NULL)
|
||||
{
|
||||
Py_CLEAR(_pyTexture);
|
||||
_pyTexture = NULL;
|
||||
}
|
||||
if (_pyWidth != NULL)
|
||||
{
|
||||
Py_CLEAR(_pyWidth);
|
||||
_pyWidth = NULL;
|
||||
}
|
||||
if (_pyHeight != NULL)
|
||||
{
|
||||
Py_CLEAR(_pyHeight);
|
||||
_pyHeight = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void TPythonScreens::reset(void *train)
|
||||
{
|
||||
_terminationFlag = true;
|
||||
if (_thread != NULL)
|
||||
{
|
||||
WriteLog("Awaiting python thread to end");
|
||||
WaitForSingleObject(_thread, INFINITE);
|
||||
_thread = NULL;
|
||||
}
|
||||
_terminationFlag = false;
|
||||
_cleanupReadyFlag = false;
|
||||
_renderReadyFlag = false;
|
||||
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin(); i != _screens.end();
|
||||
++i)
|
||||
{
|
||||
delete *i;
|
||||
}
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Clearing renderer vector");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
_screens.clear();
|
||||
_train = train;
|
||||
}
|
||||
|
||||
void TPythonScreens::init(TQueryParserComp *parser, TModel3d *model, AnsiString name, int cab)
|
||||
{
|
||||
char buff[255];
|
||||
AnsiString asSubModelName = parser->GetNextSymbol();
|
||||
AnsiString asPyClassName = parser->GetNextSymbol();
|
||||
char *subModelName = (char *)calloc(asSubModelName.Length() + 1, sizeof(char));
|
||||
strcpy(subModelName, asSubModelName.LowerCase().c_str());
|
||||
char *pyClassName = (char *)calloc(asPyClassName.Length() + 1, sizeof(char));
|
||||
strcpy(pyClassName, asPyClassName.LowerCase().c_str());
|
||||
TSubModel *subModel = model->GetFromName(subModelName);
|
||||
if (subModel == NULL)
|
||||
{
|
||||
sprintf(buff, "Python Screen: submodel %s not found - Ignoring screen", subModelName);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
return; // nie ma takiego sub modelu w danej kabinie pomijamy
|
||||
}
|
||||
int textureId = subModel->GetTextureId();
|
||||
if (textureId <= 0)
|
||||
{
|
||||
sprintf(buff, "Python Screen: invalid texture id %d - Ignoring screen", textureId);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
return; // sub model nie posiada tekstury lub tekstura wymienna - nie obslugiwana
|
||||
}
|
||||
TPythonInterpreter *python = TPythonInterpreter::getInstance();
|
||||
python->loadClassFile(_lookupPath, pyClassName);
|
||||
PyObject *args = Py_BuildValue("(ssi)", _lookupPath, name.c_str(), cab);
|
||||
if (args == NULL)
|
||||
{
|
||||
WriteLog("Python Screen: cannot create __init__ arguments");
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
return;
|
||||
}
|
||||
PyObject *pyRenderer = python->newClass(pyClassName, args);
|
||||
Py_CLEAR(args);
|
||||
if (pyRenderer == NULL)
|
||||
{
|
||||
sprintf(buff, "Python Screen: null renderer for %s - Ignoring screen", pyClassName);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
return; // nie mozna utworzyc obiektu Pythonowego
|
||||
}
|
||||
TPythonScreenRenderer *renderer = new TPythonScreenRenderer(textureId, pyRenderer);
|
||||
_screens.push_back(renderer);
|
||||
sprintf(buff, "Created python screen %s on submodel %s (%d)", pyClassName, subModelName,
|
||||
textureId);
|
||||
WriteLog(buff);
|
||||
free(subModelName);
|
||||
free(pyClassName);
|
||||
}
|
||||
|
||||
void TPythonScreens::update()
|
||||
{
|
||||
if (!_renderReadyFlag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_renderReadyFlag = false;
|
||||
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin(); i != _screens.end();
|
||||
++i)
|
||||
{
|
||||
(*i)->updateTexture();
|
||||
}
|
||||
_cleanupReadyFlag = true;
|
||||
}
|
||||
|
||||
void TPythonScreens::setLookupPath(AnsiString path)
|
||||
{
|
||||
if (_lookupPath != NULL)
|
||||
{
|
||||
free(_lookupPath);
|
||||
}
|
||||
_lookupPath = (char *)calloc(path.Length() + 1, sizeof(char));
|
||||
strcpy(_lookupPath, path.c_str());
|
||||
}
|
||||
|
||||
TPythonScreens::TPythonScreens()
|
||||
{
|
||||
_lookupPath = NULL;
|
||||
TPythonInterpreter::getInstance()->loadClassFile(NULL, "abstractscreenrenderer");
|
||||
_terminationFlag = false;
|
||||
_renderReadyFlag = false;
|
||||
_cleanupReadyFlag = false;
|
||||
_thread = NULL;
|
||||
}
|
||||
|
||||
TPythonScreens::~TPythonScreens()
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Called python sceeens destructor");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
reset(NULL);
|
||||
if (_lookupPath != NULL)
|
||||
{
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Freeing lookup path");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
free(_lookupPath);
|
||||
}
|
||||
}
|
||||
|
||||
void TPythonScreens::run()
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (_terminationFlag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TTrain *train = (TTrain *)_train;
|
||||
_trainState = train->GetTrainState();
|
||||
if (_terminationFlag)
|
||||
{
|
||||
_freeTrainState();
|
||||
return;
|
||||
}
|
||||
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin();
|
||||
i != _screens.end(); ++i)
|
||||
{
|
||||
(*i)->render(_trainState);
|
||||
}
|
||||
_freeTrainState();
|
||||
if (_terminationFlag)
|
||||
{
|
||||
_cleanup();
|
||||
return;
|
||||
}
|
||||
_renderReadyFlag = true;
|
||||
while (!_cleanupReadyFlag && !_terminationFlag)
|
||||
{
|
||||
Sleep(100);
|
||||
}
|
||||
if (_terminationFlag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void TPythonScreens::finish()
|
||||
{
|
||||
_thread == NULL;
|
||||
}
|
||||
|
||||
DWORD WINAPI ScreenRendererThread(LPVOID lpParam)
|
||||
{
|
||||
TPythonScreens *renderer = (TPythonScreens *)lpParam;
|
||||
renderer->run();
|
||||
renderer->finish();
|
||||
#ifdef _PY_INT_MORE_LOG
|
||||
WriteLog("Python Screen Renderer Thread Ends");
|
||||
#endif // _PY_INT_MORE_LOG
|
||||
return true;
|
||||
}
|
||||
|
||||
void TPythonScreens::start()
|
||||
{
|
||||
if (_screens.size() > 0)
|
||||
{
|
||||
_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ScreenRendererThread, this,
|
||||
CREATE_SUSPENDED, &_threadId);
|
||||
if (_thread != NULL)
|
||||
{
|
||||
SetThreadPriority(_thread,
|
||||
TPythonInterpreter::getInstance()->getScreenRendererPriotity());
|
||||
if (ResumeThread(_thread) != (DWORD)-1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
WriteLog("Python Screen Renderer Thread Did Not Start");
|
||||
}
|
||||
}
|
||||
|
||||
void TPythonScreens::_cleanup()
|
||||
{
|
||||
_cleanupReadyFlag = false;
|
||||
for (std::vector<TPythonScreenRenderer *>::iterator i = _screens.begin(); i != _screens.end();
|
||||
++i)
|
||||
{
|
||||
(*i)->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void TPythonScreens::_freeTrainState()
|
||||
{
|
||||
if (_trainState != NULL)
|
||||
{
|
||||
PyDict_Clear(_trainState);
|
||||
Py_CLEAR(_trainState);
|
||||
_trainState = NULL;
|
||||
}
|
||||
}
|
||||
95
PyInt.h
Normal file
95
PyInt.h
Normal file
@@ -0,0 +1,95 @@
|
||||
#ifndef PyIntH
|
||||
#define PyIntH
|
||||
|
||||
#undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu
|
||||
|
||||
#include "Python.h"
|
||||
#include "QueryParserComp.hpp"
|
||||
#include "Model3d.h"
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#define PyGetFloat(param) PyFloat_FromDouble(param >= 0 ? param : -param)
|
||||
#define PyGetInt(param) PyInt_FromLong(param)
|
||||
#define PyGetBool(param) param ? Py_True : Py_False
|
||||
|
||||
struct ltstr
|
||||
{
|
||||
bool operator()(const char *s1, const char *s2) const
|
||||
{
|
||||
return strcmp(s1, s2) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
class TPythonInterpreter
|
||||
{
|
||||
protected:
|
||||
TPythonInterpreter();
|
||||
~TPythonInterpreter()
|
||||
{
|
||||
}
|
||||
static TPythonInterpreter *_instance;
|
||||
int _screenRendererPriority;
|
||||
std::set<const char *, ltstr> _classes;
|
||||
PyObject *_main;
|
||||
PyObject *_stdErr;
|
||||
FILE *_getFile(const char *lookupPath, const char *className);
|
||||
|
||||
public:
|
||||
static TPythonInterpreter *getInstance();
|
||||
bool loadClassFile(const char *lookupPath, const char *className);
|
||||
PyObject *newClass(const char *className);
|
||||
PyObject *newClass(const char *className, PyObject *argsTuple);
|
||||
int getScreenRendererPriotity()
|
||||
{
|
||||
return _screenRendererPriority;
|
||||
};
|
||||
void setScreenRendererPriority(const char *priority);
|
||||
void handleError();
|
||||
};
|
||||
|
||||
class TPythonScreenRenderer
|
||||
{
|
||||
protected:
|
||||
PyObject *_pyRenderer;
|
||||
PyObject *_pyTexture;
|
||||
int _textureId;
|
||||
PyObject *_pyWidth;
|
||||
PyObject *_pyHeight;
|
||||
|
||||
public:
|
||||
TPythonScreenRenderer(int textureId, PyObject *renderer);
|
||||
~TPythonScreenRenderer();
|
||||
void render(PyObject *trainState);
|
||||
void cleanup();
|
||||
void updateTexture();
|
||||
};
|
||||
|
||||
class TPythonScreens
|
||||
{
|
||||
protected:
|
||||
bool _cleanupReadyFlag;
|
||||
bool _renderReadyFlag;
|
||||
bool _terminationFlag;
|
||||
HANDLE _thread;
|
||||
DWORD _threadId;
|
||||
std::vector<TPythonScreenRenderer *> _screens;
|
||||
char *_lookupPath;
|
||||
void *_train;
|
||||
void _cleanup();
|
||||
void _freeTrainState();
|
||||
PyObject *_trainState;
|
||||
|
||||
public:
|
||||
void reset(void *train);
|
||||
void setLookupPath(AnsiString path);
|
||||
void init(TQueryParserComp *parser, TModel3d *model, AnsiString name, int cab);
|
||||
void update();
|
||||
TPythonScreens();
|
||||
~TPythonScreens();
|
||||
void run();
|
||||
void start();
|
||||
void finish();
|
||||
};
|
||||
|
||||
#endif // PyIntH
|
||||
@@ -45,10 +45,12 @@ TRealSound::~TRealSound()
|
||||
// if (this) if (pSound) pSound->Stop();
|
||||
}
|
||||
|
||||
void TRealSound::Free() {}
|
||||
void TRealSound::Free()
|
||||
{
|
||||
}
|
||||
|
||||
void TRealSound::Init(char *SoundName, double DistanceAttenuation, double X, double Y,
|
||||
double Z, bool Dynamic, bool freqmod, double rmin)
|
||||
void TRealSound::Init(char *SoundName, double DistanceAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod, double rmin)
|
||||
{
|
||||
// Nazwa=SoundName; //to tak raczej nie zadziała, (SoundName) jest tymczasowe
|
||||
pSound = TSoundsManager::GetFromName(SoundName, Dynamic, &fFrequency);
|
||||
@@ -95,8 +97,7 @@ double TRealSound::ListenerDistance(vector3 ListenerPosition)
|
||||
}
|
||||
}
|
||||
|
||||
void TRealSound::Play(double Volume, int Looping, bool ListenerInside,
|
||||
vector3 NewPosition)
|
||||
void TRealSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition)
|
||||
{
|
||||
if (!pSound)
|
||||
return;
|
||||
@@ -168,7 +169,8 @@ void TRealSound::Play(double Volume, int Looping, bool ListenerInside,
|
||||
}
|
||||
};
|
||||
|
||||
void TRealSound::Start(){// włączenie dźwięku
|
||||
void TRealSound::Start(){
|
||||
// włączenie dźwięku
|
||||
|
||||
};
|
||||
|
||||
@@ -185,8 +187,7 @@ void TRealSound::Stop()
|
||||
}
|
||||
};
|
||||
|
||||
void TRealSound::AdjFreq(double Freq,
|
||||
double dt) // McZapkie TODO: dorobic tu efekt Dopplera
|
||||
void TRealSound::AdjFreq(double Freq, double dt) // McZapkie TODO: dorobic tu efekt Dopplera
|
||||
// Freq moze byc liczba dodatnia mniejsza od 1 lub wieksza od 1
|
||||
{
|
||||
float df, Vlist, Vsrc;
|
||||
@@ -223,7 +224,10 @@ double TRealSound::GetWaveTime() // McZapkie: na razie tylko dla 22KHz/8bps
|
||||
fFrequency; //(pSound->); // wielkosc w bajtach przez czestotliwosc probkowania
|
||||
}
|
||||
|
||||
void TRealSound::SetPan(int Pan) { pSound->SetPan(Pan); }
|
||||
void TRealSound::SetPan(int Pan)
|
||||
{
|
||||
pSound->SetPan(Pan);
|
||||
}
|
||||
|
||||
int TRealSound::GetStatus()
|
||||
{
|
||||
@@ -243,8 +247,8 @@ void TRealSound::ResetPosition()
|
||||
pSound->SetCurrentPosition(0);
|
||||
}
|
||||
|
||||
void TTextSound::Init(char *SoundName, double SoundAttenuation, double X, double Y,
|
||||
double Z, bool Dynamic, bool freqmod, double rmin)
|
||||
void TTextSound::Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod, double rmin)
|
||||
{ // dodatkowo doczytuje plik tekstowy
|
||||
TRealSound::Init(SoundName, SoundAttenuation, X, Y, Z, Dynamic, freqmod, rmin);
|
||||
fTime = GetWaveTime();
|
||||
@@ -264,8 +268,7 @@ void TTextSound::Init(char *SoundName, double SoundAttenuation, double X, double
|
||||
delete ts;
|
||||
}
|
||||
};
|
||||
void TTextSound::Play(double Volume, int Looping, bool ListenerInside,
|
||||
vector3 NewPosition)
|
||||
void TTextSound::Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition)
|
||||
{
|
||||
if (!asText.IsEmpty())
|
||||
{ // jeśli ma powiązany tekst
|
||||
|
||||
@@ -32,8 +32,8 @@ class TRealSound
|
||||
TRealSound();
|
||||
~TRealSound();
|
||||
void Free();
|
||||
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod = false, double rmin = 0.0);
|
||||
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
|
||||
bool freqmod = false, double rmin = 0.0);
|
||||
double ListenerDistance(vector3 ListenerPosition);
|
||||
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
|
||||
void Start();
|
||||
@@ -51,8 +51,8 @@ class TTextSound : public TRealSound
|
||||
AnsiString asText;
|
||||
float fTime; // czas trwania
|
||||
public:
|
||||
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z,
|
||||
bool Dynamic, bool freqmod = false, double rmin = 0.0);
|
||||
void Init(char *SoundName, double SoundAttenuation, double X, double Y, double Z, bool Dynamic,
|
||||
bool freqmod = false, double rmin = 0.0);
|
||||
void Play(double Volume, int Looping, bool ListenerInside, vector3 NewPosition);
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ double ResourceManager::_expiry = 5.0f;
|
||||
double ResourceManager::_lastUpdate = 0.0f;
|
||||
double ResourceManager::_lastReport = 0.0f;
|
||||
|
||||
void ResourceManager::Register(Resource *resource) { _resources.push_back(resource); };
|
||||
void ResourceManager::Register(Resource *resource)
|
||||
{
|
||||
_resources.push_back(resource);
|
||||
};
|
||||
|
||||
void ResourceManager::Unregister(Resource *resource)
|
||||
{
|
||||
@@ -33,7 +36,10 @@ class ResourceExpired
|
||||
{
|
||||
public:
|
||||
ResourceExpired(double time) : _time(time){};
|
||||
bool operator()(Resource *resource) { return (resource->GetLastUsage() < _time); }
|
||||
bool operator()(Resource *resource)
|
||||
{
|
||||
return (resource->GetLastUsage() < _time);
|
||||
}
|
||||
|
||||
private:
|
||||
double _time;
|
||||
|
||||
@@ -20,10 +20,16 @@ class Resource
|
||||
|
||||
public:
|
||||
virtual void Release() = 0;
|
||||
double GetLastUsage() const { return _lastUsage; }
|
||||
double GetLastUsage() const
|
||||
{
|
||||
return _lastUsage;
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetLastUsage(double lastUsage) { _lastUsage = lastUsage; }
|
||||
void SetLastUsage(double lastUsage)
|
||||
{
|
||||
_lastUsage = lastUsage;
|
||||
}
|
||||
|
||||
private:
|
||||
double _lastUsage;
|
||||
@@ -37,7 +43,10 @@ class ResourceManager
|
||||
static void Unregister(Resource *resource);
|
||||
|
||||
static void Sweep(double currentTime);
|
||||
static void SetExpiry(double expiry) { _expiry = expiry; }
|
||||
static void SetExpiry(double expiry)
|
||||
{
|
||||
_expiry = expiry;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::vector<Resource *> Resources;
|
||||
|
||||
28
Segment.cpp
28
Segment.cpp
@@ -41,10 +41,13 @@ TSegment::TSegment(TTrack *owner)
|
||||
pOwner = owner;
|
||||
};
|
||||
|
||||
TSegment::~TSegment() { SafeDeleteArray(fTsBuffer); };
|
||||
TSegment::~TSegment()
|
||||
{
|
||||
SafeDeleteArray(fTsBuffer);
|
||||
};
|
||||
|
||||
bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep,
|
||||
double fNewRoll1, double fNewRoll2)
|
||||
bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1,
|
||||
double fNewRoll2)
|
||||
{ // wersja dla prostego - wyliczanie punktów kontrolnych
|
||||
vector3 dir;
|
||||
if (fNewRoll1 == fNewRoll2)
|
||||
@@ -62,8 +65,8 @@ bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep,
|
||||
};
|
||||
|
||||
bool TSegment::Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn,
|
||||
vector3 &NewPoint2, double fNewStep, double fNewRoll1,
|
||||
double fNewRoll2, bool bIsCurve)
|
||||
vector3 &NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2,
|
||||
bool bIsCurve)
|
||||
{ // wersja uniwersalna (dla krzywej i prostego)
|
||||
Point1 = NewPoint1;
|
||||
CPointOut = NewCPointOut;
|
||||
@@ -329,9 +332,8 @@ vector3 TSegment::FastGetPoint(double t)
|
||||
return (bCurve ? RaInterpolate(t) : ((1.0 - t) * Point1 + (t)*Point2));
|
||||
}
|
||||
|
||||
void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints,
|
||||
double fTextureLength, int iSkip, int iQualityFactor,
|
||||
vector3 **p, bool bRender)
|
||||
void TSegment::RenderLoft(const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength,
|
||||
int iSkip, int iQualityFactor, vector3 **p, bool bRender)
|
||||
{ // generowanie trójkątów dla odcinka trajektorii ruchu
|
||||
// standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku
|
||||
// po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli
|
||||
@@ -696,9 +698,8 @@ void TSegment::Render()
|
||||
}
|
||||
}
|
||||
|
||||
void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints,
|
||||
int iNumShapePoints, double fTextureLength, int iSkip,
|
||||
int iEnd, double fOffsetX)
|
||||
void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
|
||||
double fTextureLength, int iSkip, int iEnd, double fOffsetX)
|
||||
{ // generowanie trójkątów dla odcinka trajektorii ruchu
|
||||
// standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku
|
||||
// po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli
|
||||
@@ -896,9 +897,8 @@ void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints,
|
||||
}
|
||||
};
|
||||
|
||||
void TSegment::RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints,
|
||||
int iNumShapePoints, double fTextureLength, int iSkip, int iEnd,
|
||||
double fOffsetX)
|
||||
void TSegment::RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
|
||||
double fTextureLength, int iSkip, int iEnd, double fOffsetX)
|
||||
{ // jak wyżej, tylko z pominięciem mapowania i braku trapezowania
|
||||
vector3 pos1, pos2, dir, parallel1, parallel2, pt;
|
||||
double s, step, fOffset, t, fEnd;
|
||||
|
||||
62
Segment.h
62
Segment.h
@@ -77,22 +77,36 @@ class TSegment
|
||||
// (0-Bezier,1-prosty,2/3-³uk w lewo/prawo,6/7-przejœciowa w lewo/prawo)
|
||||
TSegment(TTrack *owner);
|
||||
~TSegment();
|
||||
bool Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep,
|
||||
double fNewRoll1 = 0, double fNewRoll2 = 0);
|
||||
bool Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn,
|
||||
vector3 &NewPoint2, double fNewStep, double fNewRoll1 = 0,
|
||||
double fNewRoll2 = 0, bool bIsCurve = true);
|
||||
bool Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1 = 0,
|
||||
double fNewRoll2 = 0);
|
||||
bool Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn, vector3 &NewPoint2,
|
||||
double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true);
|
||||
inline double ComputeLength(); // McZapkie-150503
|
||||
inline vector3 GetDirection1() { return bCurve ? CPointOut - Point1 : CPointOut; };
|
||||
inline vector3 GetDirection2() { return bCurve ? CPointIn - Point2 : CPointIn; };
|
||||
inline vector3 GetDirection1()
|
||||
{
|
||||
return bCurve ? CPointOut - Point1 : CPointOut;
|
||||
};
|
||||
inline vector3 GetDirection2()
|
||||
{
|
||||
return bCurve ? CPointIn - Point2 : CPointIn;
|
||||
};
|
||||
vector3 GetDirection(double fDistance);
|
||||
vector3 GetDirection() { return CPointOut; };
|
||||
vector3 GetDirection()
|
||||
{
|
||||
return CPointOut;
|
||||
};
|
||||
vector3 FastGetDirection(double fDistance, double fOffset);
|
||||
vector3 GetPoint(double fDistance);
|
||||
void RaPositionGet(double fDistance, vector3 &p, vector3 &a);
|
||||
vector3 FastGetPoint(double t);
|
||||
inline vector3 FastGetPoint_0() { return Point1; };
|
||||
inline vector3 FastGetPoint_1() { return Point2; };
|
||||
inline vector3 FastGetPoint_0()
|
||||
{
|
||||
return Point1;
|
||||
};
|
||||
inline vector3 FastGetPoint_1()
|
||||
{
|
||||
return Point2;
|
||||
};
|
||||
inline double GetRoll(double s)
|
||||
{
|
||||
s /= fLength;
|
||||
@@ -103,14 +117,16 @@ class TSegment
|
||||
r1 = fRoll1;
|
||||
r2 = fRoll2;
|
||||
}
|
||||
void RenderLoft(const vector6 *ShapePoints, int iNumShapePoints,
|
||||
double fTextureLength, int iSkip = 0, int iQualityFactor = 1,
|
||||
vector3 **p = NULL, bool bRender = true);
|
||||
void RenderLoft(const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength,
|
||||
int iSkip = 0, int iQualityFactor = 1, vector3 **p = NULL, bool bRender = true);
|
||||
void RenderSwitchRail(const vector6 *ShapePoints1, const vector6 *ShapePoints2,
|
||||
int iNumShapePoints, double fTextureLength, int iSkip = 0,
|
||||
double fOffsetX = 0.0f);
|
||||
void Render();
|
||||
inline double GetLength() { return fLength; };
|
||||
inline double GetLength()
|
||||
{
|
||||
return fLength;
|
||||
};
|
||||
void MoveMe(vector3 pPosition)
|
||||
{
|
||||
Point1 += pPosition;
|
||||
@@ -121,14 +137,18 @@ class TSegment
|
||||
CPointOut += pPosition;
|
||||
}
|
||||
}
|
||||
int RaSegCount() { return fTsBuffer ? iSegCount : 1; };
|
||||
void RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints,
|
||||
int iNumShapePoints, double fTextureLength, int iSkip = 0,
|
||||
int iEnd = 0, double fOffsetX = 0.0);
|
||||
int RaSegCount()
|
||||
{
|
||||
return fTsBuffer ? iSegCount : 1;
|
||||
};
|
||||
void RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
|
||||
double fTextureLength, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0);
|
||||
void RaAnimate(CVertNormTex *&Vert, const vector6 *ShapePoints, int iNumShapePoints,
|
||||
double fTextureLength, int iSkip = 0, int iEnd = 0,
|
||||
double fOffsetX = 0.0);
|
||||
void AngleSet(int i, double a) { fAngle[i] = a; };
|
||||
double fTextureLength, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0);
|
||||
void AngleSet(int i, double a)
|
||||
{
|
||||
fAngle[i] = a;
|
||||
};
|
||||
void Rollment(double w1, double w2); // poprawianie przechy³ki
|
||||
};
|
||||
|
||||
|
||||
@@ -171,7 +171,10 @@ LPDIRECTSOUNDBUFFER TSoundContainer::GetUnique(LPDIRECTSOUND pDS)
|
||||
return DSBuffers.top();
|
||||
};
|
||||
|
||||
TSoundsManager::~TSoundsManager() { Free(); };
|
||||
TSoundsManager::~TSoundsManager()
|
||||
{
|
||||
Free();
|
||||
};
|
||||
|
||||
void TSoundsManager::Free()
|
||||
{
|
||||
@@ -200,8 +203,7 @@ void TSoundsManager::LoadSounds(char *Directory)
|
||||
FindClose(handle);
|
||||
};
|
||||
|
||||
LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(char *Name, bool Dynamic,
|
||||
float *fSamplingRate)
|
||||
LPDIRECTSOUNDBUFFER TSoundsManager::GetFromName(char *Name, bool Dynamic, float *fSamplingRate)
|
||||
{ // wyszukanie dŸwiêku w pamiêci albo wczytanie z pliku
|
||||
AnsiString file;
|
||||
if (Dynamic)
|
||||
|
||||
6
Sound.h
6
Sound.h
@@ -39,8 +39,7 @@ class TSoundContainer
|
||||
TSoundContainer *Next;
|
||||
std::stack<LPDIRECTSOUNDBUFFER> DSBuffers;
|
||||
LPDIRECTSOUNDBUFFER GetUnique(LPDIRECTSOUND pDS);
|
||||
TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFileName,
|
||||
int NConcurrent);
|
||||
TSoundContainer(LPDIRECTSOUND pDS, char *Directory, char *strFileName, int NConcurrent);
|
||||
~TSoundContainer();
|
||||
};
|
||||
|
||||
@@ -62,8 +61,7 @@ class TSoundsManager
|
||||
static void Free();
|
||||
static void Init(char *Name, int Concurrent);
|
||||
static void LoadSounds(char *Directory);
|
||||
static LPDIRECTSOUNDBUFFER GetFromName(char *Name, bool Dynamic,
|
||||
float *fSamplingRate = NULL);
|
||||
static LPDIRECTSOUNDBUFFER GetFromName(char *Name, bool Dynamic, float *fSamplingRate = NULL);
|
||||
static void RestoreAll();
|
||||
};
|
||||
|
||||
|
||||
@@ -73,7 +73,9 @@ __fastcall TKnot::TKnot(int n)
|
||||
}
|
||||
}
|
||||
|
||||
__fastcall TKnot::~TKnot() {}
|
||||
__fastcall TKnot::~TKnot()
|
||||
{
|
||||
}
|
||||
|
||||
vector3 TKnot::GetDirection(float t)
|
||||
{
|
||||
|
||||
10
Spring.cpp
10
Spring.cpp
@@ -24,7 +24,9 @@ TSpring::TSpring()
|
||||
restLen = 0;
|
||||
}
|
||||
|
||||
TSpring::~TSpring() {}
|
||||
TSpring::~TSpring()
|
||||
{
|
||||
}
|
||||
|
||||
void TSpring::Init(double nrestLen, double nKs, double nKd)
|
||||
{
|
||||
@@ -43,7 +45,7 @@ bool TSpring::ComputateForces(vector3 pPosition1, vector3 pPosition2)
|
||||
// VectorDifference(&p1->pos,&p2->pos,&deltaP); // Vector distance
|
||||
deltaP = pPosition1 - pPosition2;
|
||||
// dist = VectorLength(&deltaP); // Magnitude of
|
||||
//deltaP
|
||||
// deltaP
|
||||
dist = deltaP.Length();
|
||||
if (dist == 0)
|
||||
{
|
||||
@@ -72,7 +74,9 @@ bool TSpring::ComputateForces(vector3 pPosition1, vector3 pPosition2)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TSpring::Render() {}
|
||||
void TSpring::Render()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -89,7 +89,10 @@ TTexturesManager::Names::iterator TTexturesManager::LoadFromFile(std::string fil
|
||||
|
||||
struct ReplaceSlash
|
||||
{
|
||||
const char operator()(const char input) { return input == '/' ? '\\' : input; }
|
||||
const char operator()(const char input)
|
||||
{
|
||||
return input == '/' ? '\\' : input;
|
||||
}
|
||||
};
|
||||
|
||||
GLuint TTexturesManager::GetTextureID(char *dir, char *where, std::string fileName, int filter)
|
||||
|
||||
33
Timer.cpp
33
Timer.cpp
@@ -25,7 +25,10 @@ double fSimulationTime = 0;
|
||||
double fSoundTimer = 0;
|
||||
double fSinceStart = 0;
|
||||
|
||||
double GetTime() { return fSimulationTime; }
|
||||
double GetTime()
|
||||
{
|
||||
return fSimulationTime;
|
||||
}
|
||||
|
||||
double GetDeltaTime()
|
||||
{ // czas symulacji (stoi gdy pauza)
|
||||
@@ -37,19 +40,35 @@ double GetDeltaRenderTime()
|
||||
return DeltaRenderTime;
|
||||
}
|
||||
|
||||
double GetfSinceStart() { return fSinceStart; }
|
||||
double GetfSinceStart()
|
||||
{
|
||||
return fSinceStart;
|
||||
}
|
||||
|
||||
void SetDeltaTime(double t) { DeltaTime = t; }
|
||||
void SetDeltaTime(double t)
|
||||
{
|
||||
DeltaTime = t;
|
||||
}
|
||||
|
||||
double GetSimulationTime() { return fSimulationTime; }
|
||||
double GetSimulationTime()
|
||||
{
|
||||
return fSimulationTime;
|
||||
}
|
||||
|
||||
void SetSimulationTime(double t) { fSimulationTime = t; }
|
||||
void SetSimulationTime(double t)
|
||||
{
|
||||
fSimulationTime = t;
|
||||
}
|
||||
|
||||
bool GetSoundTimer()
|
||||
{ // Ra: byæ mo¿e, by dŸwiêki nie modyfikowa³y siê zbyt czêsto, po 0.1s zeruje siê ten licznik
|
||||
return (fSoundTimer == 0.0f); }
|
||||
return (fSoundTimer == 0.0f);
|
||||
}
|
||||
|
||||
double GetFPS() { return fFPS; }
|
||||
double GetFPS()
|
||||
{
|
||||
return fFPS;
|
||||
}
|
||||
|
||||
void ResetTimers()
|
||||
{
|
||||
|
||||
@@ -68,8 +68,8 @@ TSwitchExtension::TSwitchExtension(TTrack *owner, int what)
|
||||
Segments[2] = (what >= 3) ?
|
||||
new TSegment(owner) :
|
||||
NULL; // z punktu 2 do 4 skrzyżowanie od góry: wersja "-1":
|
||||
Segments[3] = (what >= 4) ? new TSegment(owner) :
|
||||
NULL; // z punktu 4 do 1 1 1=4 0 0=3
|
||||
Segments[3] =
|
||||
(what >= 4) ? new TSegment(owner) : NULL; // z punktu 4 do 1 1 1=4 0 0=3
|
||||
Segments[4] =
|
||||
(what >= 5) ? new TSegment(owner) : NULL; // z punktu 1 do 3 4 x 3 3 3 x 2 2
|
||||
Segments[5] = (what >= 6) ? new TSegment(owner) :
|
||||
@@ -102,7 +102,8 @@ TIsolated::TIsolated(const AnsiString &n, TIsolated *i)
|
||||
pMemCell = NULL; // podpiąć istniejącą albo utworzyć pustą
|
||||
};
|
||||
|
||||
TIsolated::~TIsolated(){// usuwanie
|
||||
TIsolated::~TIsolated(){
|
||||
// usuwanie
|
||||
/*
|
||||
TIsolated *p=pRoot;
|
||||
while (pRoot)
|
||||
|
||||
45
Track.h
45
Track.h
@@ -111,9 +111,18 @@ class TIsolated
|
||||
static TIsolated *__fastcall Find(
|
||||
const AnsiString &n); // znalezienie obiektu albo utworzenie nowego
|
||||
void Modify(int i, TDynamicObject *o); // dodanie lub odjęcie osi
|
||||
bool Busy() { return (iAxles > 0); };
|
||||
static TIsolated *__fastcall Root() { return (pRoot); };
|
||||
TIsolated *__fastcall Next() { return (pNext); };
|
||||
bool Busy()
|
||||
{
|
||||
return (iAxles > 0);
|
||||
};
|
||||
static TIsolated *__fastcall Root()
|
||||
{
|
||||
return (pRoot);
|
||||
};
|
||||
TIsolated *__fastcall Next()
|
||||
{
|
||||
return (pNext);
|
||||
};
|
||||
};
|
||||
|
||||
class TTrack : public Resource
|
||||
@@ -185,15 +194,30 @@ class TTrack : public Resource
|
||||
void Init();
|
||||
static TTrack *__fastcall Create400m(int what, double dx);
|
||||
TTrack *__fastcall NullCreate(int dir);
|
||||
inline bool IsEmpty() { return (iNumDynamics <= 0); };
|
||||
inline bool IsEmpty()
|
||||
{
|
||||
return (iNumDynamics <= 0);
|
||||
};
|
||||
void ConnectPrevPrev(TTrack *pNewPrev, int typ);
|
||||
void ConnectPrevNext(TTrack *pNewPrev, int typ);
|
||||
void ConnectNextPrev(TTrack *pNewNext, int typ);
|
||||
void ConnectNextNext(TTrack *pNewNext, int typ);
|
||||
inline double Length() { return Segment->GetLength(); };
|
||||
inline TSegment *__fastcall CurrentSegment() { return Segment; };
|
||||
inline TTrack *__fastcall CurrentNext() { return (trNext); };
|
||||
inline TTrack *__fastcall CurrentPrev() { return (trPrev); };
|
||||
inline double Length()
|
||||
{
|
||||
return Segment->GetLength();
|
||||
};
|
||||
inline TSegment *__fastcall CurrentSegment()
|
||||
{
|
||||
return Segment;
|
||||
};
|
||||
inline TTrack *__fastcall CurrentNext()
|
||||
{
|
||||
return (trNext);
|
||||
};
|
||||
inline TTrack *__fastcall CurrentPrev()
|
||||
{
|
||||
return (trPrev);
|
||||
};
|
||||
TTrack *__fastcall Neightbour(int s, double &d);
|
||||
bool SetConnections(int i);
|
||||
bool Switch(int i, double t = -1.0, double d = -1.0);
|
||||
@@ -244,7 +268,10 @@ class TTrack : public Resource
|
||||
AnsiString IsolatedName();
|
||||
bool IsolatedEventsAssign(TEvent *busy, TEvent *free);
|
||||
double WidthTotal();
|
||||
GLuint TextureGet(int i) { return i ? TextureID1 : TextureID2; };
|
||||
GLuint TextureGet(int i)
|
||||
{
|
||||
return i ? TextureID1 : TextureID2;
|
||||
};
|
||||
bool IsGroupable();
|
||||
int TestPoint(vector3 *Point);
|
||||
void MovedUp1(double dh);
|
||||
|
||||
@@ -86,13 +86,15 @@ bool TTractionPowerSource::Load(cParser *parser)
|
||||
Error("tractionpowersource end statement missing");
|
||||
// if (!bSection) //od³¹cznik sekcji zasadniczo nie ma impedancji (0.01 jest OK)
|
||||
if (InternalRes < 0.1) // coœ ma³a ta rezystancja by³a...
|
||||
InternalRes =
|
||||
0.2; // tak oko³o 0.2, wg
|
||||
InternalRes = 0.2; // tak oko³o 0.2, wg
|
||||
// http://www.ikolej.pl/fileadmin/user_upload/Seminaria_IK/13_05_07_Prezentacja_Kruczek.pdf
|
||||
return true;
|
||||
};
|
||||
|
||||
bool TTractionPowerSource::Render() { return true; };
|
||||
bool TTractionPowerSource::Render()
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
bool TTractionPowerSource::Update(double dt)
|
||||
{ // powinno byæ wykonane raz na krok fizyki
|
||||
|
||||
@@ -48,7 +48,10 @@ class TTractionPowerSource
|
||||
bool Render();
|
||||
bool Update(double dt);
|
||||
double CurrentGet(double res);
|
||||
void VoltageSet(double v) { NominalVoltage = v; };
|
||||
void VoltageSet(double v)
|
||||
{
|
||||
NominalVoltage = v;
|
||||
};
|
||||
void PowerSet(TTractionPowerSource *ps);
|
||||
};
|
||||
|
||||
|
||||
49
Train.cpp
49
Train.cpp
@@ -49,8 +49,8 @@ TCab::TCab()
|
||||
iButtons = 0;
|
||||
}
|
||||
|
||||
void TCab::Init(double Initx1, double Inity1, double Initz1, double Initx2,
|
||||
double Inity2, double Initz2, bool InitEnabled, bool InitOccupied)
|
||||
void TCab::Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2,
|
||||
double Initz2, bool InitEnabled, bool InitOccupied)
|
||||
{
|
||||
CabPos1.x = Initx1;
|
||||
CabPos1.y = Inity1;
|
||||
@@ -260,6 +260,38 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
|
||||
return true;
|
||||
}
|
||||
|
||||
PyObject *TTrain::GetTrainState()
|
||||
{
|
||||
PyObject *dict = PyDict_New();
|
||||
if (dict == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyDict_SetItemString(dict, "direction", PyGetInt(DynamicObject->MoverParameters->ActiveDir));
|
||||
PyDict_SetItemString(dict, "slipping_wheels",
|
||||
PyGetBool(DynamicObject->MoverParameters->SlippingWheels));
|
||||
PyDict_SetItemString(dict, "converter",
|
||||
PyGetBool(DynamicObject->MoverParameters->ConverterFlag));
|
||||
PyDict_SetItemString(dict, "main_ctrl_actual_pos",
|
||||
PyGetInt(DynamicObject->MoverParameters->MainCtrlActualPos));
|
||||
PyDict_SetItemString(dict, "scnd_ctrl_actual_pos",
|
||||
PyGetInt(DynamicObject->MoverParameters->ScndCtrlActualPos));
|
||||
PyDict_SetItemString(dict, "fuse", PyGetBool(DynamicObject->MoverParameters->FuseFlag));
|
||||
PyDict_SetItemString(dict, "converter_overload",
|
||||
PyGetBool(DynamicObject->MoverParameters->ConvOvldFlag));
|
||||
PyDict_SetItemString(dict, "voltage", PyGetFloat(DynamicObject->MoverParameters->Voltage));
|
||||
PyDict_SetItemString(dict, "velocity", PyGetFloat(DynamicObject->MoverParameters->Vel));
|
||||
PyDict_SetItemString(dict, "im", PyGetFloat(DynamicObject->MoverParameters->Im));
|
||||
PyDict_SetItemString(dict, "compress",
|
||||
PyGetBool(DynamicObject->MoverParameters->CompressorFlag));
|
||||
PyDict_SetItemString(dict, "hours", PyGetInt(GlobalTime->hh));
|
||||
PyDict_SetItemString(dict, "minutes", PyGetInt(GlobalTime->mm));
|
||||
PyDict_SetItemString(dict, "seconds", PyGetInt(GlobalTime->mr));
|
||||
PyDict_SetItemString(dict, "velocity_desired", PyGetFloat(DynamicObject->Mechanik->VelDesired));
|
||||
return dict;
|
||||
}
|
||||
|
||||
void TTrain::OnKeyDown(int cKey)
|
||||
{ // naciœniêcie klawisza
|
||||
bool isEztOer;
|
||||
@@ -2481,8 +2513,8 @@ bool TTrain::Update()
|
||||
5, fHCurrent[(mvControlled->TrainType & dt_EZT) ? 0 : 1]); // pierwszy amperomierz;
|
||||
// dla EZT pr¹d ca³kowity
|
||||
Console::ValueSet(6, fTachoVelocity); ////Ra: prêdkoœæ na pin 43 - wyjœcie analogowe (to
|
||||
///nie jest PWM); skakanie zapewnia mechanika
|
||||
///napêdu
|
||||
/// nie jest PWM); skakanie zapewnia mechanika
|
||||
/// napêdu
|
||||
}
|
||||
|
||||
// hunter-080812: wyrzucanie szybkiego na elektrykach gdy nie ma napiecia przy dowolnym
|
||||
@@ -4589,6 +4621,8 @@ bool TTrain::Update()
|
||||
ggDepartureSignalButton.UpdateValue(0);
|
||||
ggFuseButton.UpdateValue(0);
|
||||
ggConverterFuseButton.UpdateValue(0);
|
||||
|
||||
pyScreens.update();
|
||||
}
|
||||
// wyprowadzenie sygna³ów dla haslera na PoKeys (zaznaczanie na taœmie)
|
||||
btHaslerBrakes.Turn(DynamicObject->MoverParameters->BrakePress > 0.4); // ciœnienie w cylindrach
|
||||
@@ -4902,6 +4936,8 @@ bool TTrain::LoadMMediaFile(AnsiString asFileName)
|
||||
|
||||
bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
|
||||
{
|
||||
pyScreens.reset(this);
|
||||
pyScreens.setLookupPath(DynamicObject->asBaseDir);
|
||||
bool parse = false;
|
||||
double dSDist;
|
||||
TFileStream *fs;
|
||||
@@ -4998,7 +5034,7 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
|
||||
if (k)
|
||||
DynamicObject->mdKabina = k; // nowa kabina
|
||||
//(mdKabina) mo¿e zostaæ to samo po przejœciu do innego cz³onu bez zmiany
|
||||
//kabiny, przy powrocie musi byæ wi¹zanie ponowne
|
||||
// kabiny, przy powrocie musi byæ wi¹zanie ponowne
|
||||
// else
|
||||
// break; //wyjœcie z pêtli, bo model zostaje bez zmian
|
||||
}
|
||||
@@ -5508,6 +5544,8 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
|
||||
btLampkaBackward.Load(Parser, DynamicObject->mdKabina);
|
||||
else if (str == AnsiString("i-cablight:")) // hunter-171012
|
||||
btCabLight.Load(Parser, DynamicObject->mdKabina);
|
||||
else if (str == AnsiString("pyscreen:"))
|
||||
pyScreens.init(Parser, DynamicObject->mdKabina, DynamicObject->GetName(), NewCabNo);
|
||||
// btLampkaUnknown.Init("unknown",mdKabina,false);
|
||||
}
|
||||
}
|
||||
@@ -5518,6 +5556,7 @@ bool TTrain::InitializeCab(int NewCabNo, AnsiString asFileName)
|
||||
}
|
||||
// ABu 050205: tego wczesniej nie bylo:
|
||||
delete Parser;
|
||||
pyScreens.start();
|
||||
if (DynamicObject->mdKabina)
|
||||
{
|
||||
DynamicObject->mdKabina
|
||||
|
||||
29
Train.h
29
Train.h
@@ -23,6 +23,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "AdvSound.h"
|
||||
#include "RealSound.h"
|
||||
#include "FadeSound.h"
|
||||
#include "PyInt.h"
|
||||
|
||||
// typedef enum {st_Off, st_Starting, st_On, st_ShuttingDown} T4State;
|
||||
|
||||
@@ -83,14 +84,21 @@ class TTrain
|
||||
|
||||
// bool SHP() { fShpTimer= 0; };
|
||||
|
||||
inline vector3 GetDirection() { return DynamicObject->VectorFront(); };
|
||||
inline vector3 GetUp() { return DynamicObject->VectorUp(); };
|
||||
inline vector3 GetDirection()
|
||||
{
|
||||
return DynamicObject->VectorFront();
|
||||
};
|
||||
inline vector3 GetUp()
|
||||
{
|
||||
return DynamicObject->VectorUp();
|
||||
};
|
||||
void UpdateMechPosition(double dt);
|
||||
bool Update();
|
||||
void MechStop();
|
||||
// virtual bool RenderAlpha();
|
||||
// McZapkie-310302: ladowanie parametrow z pliku
|
||||
bool LoadMMediaFile(AnsiString asFileName);
|
||||
PyObject *GetTrainState();
|
||||
|
||||
private: //瞠by go nic z zewn靖rz nie przestawia這
|
||||
TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5]
|
||||
@@ -372,10 +380,21 @@ class TTrain
|
||||
float fSPPress, fSNPress;
|
||||
int iSekunda; // Ra: sekunda aktualizacji pr璠ko𦣇i
|
||||
int iRadioChannel; // numer aktualnego kana逝 radiowego
|
||||
TPythonScreens pyScreens;
|
||||
|
||||
public:
|
||||
int RadioChannel() { return iRadioChannel; };
|
||||
inline TDynamicObject *__fastcall Dynamic() { return DynamicObject; };
|
||||
inline TMoverParameters *__fastcall Controlled() { return mvControlled; };
|
||||
int RadioChannel()
|
||||
{
|
||||
return iRadioChannel;
|
||||
};
|
||||
inline TDynamicObject *__fastcall Dynamic()
|
||||
{
|
||||
return DynamicObject;
|
||||
};
|
||||
inline TMoverParameters *__fastcall Controlled()
|
||||
{
|
||||
return mvControlled;
|
||||
};
|
||||
void DynamicSet(TDynamicObject *d);
|
||||
void Silence();
|
||||
};
|
||||
|
||||
@@ -37,7 +37,9 @@ TTrackFollower::TTrackFollower()
|
||||
fOffsetH = 0.0; // na starcie stoi na środku
|
||||
}
|
||||
|
||||
TTrackFollower::~TTrackFollower() {}
|
||||
TTrackFollower::~TTrackFollower()
|
||||
{
|
||||
}
|
||||
|
||||
bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, double fDir)
|
||||
{
|
||||
|
||||
15
TrkFoll.h
15
TrkFoll.h
@@ -35,14 +35,23 @@ class TTrackFollower
|
||||
~TTrackFollower();
|
||||
TTrack *__fastcall SetCurrentTrack(TTrack *pTrack, int end);
|
||||
bool Move(double fDistance, bool bPrimary);
|
||||
inline TTrack *__fastcall GetTrack() { return pCurrentTrack; };
|
||||
inline TTrack *__fastcall GetTrack()
|
||||
{
|
||||
return pCurrentTrack;
|
||||
};
|
||||
inline double GetRoll()
|
||||
{
|
||||
return vAngles.x;
|
||||
}; // przechy³ka policzona przy ustalaniu pozycji
|
||||
//{return pCurrentSegment->GetRoll(fCurrentDistance)*fDirection;}; //zamiast liczyæ mo¿na pobraæ
|
||||
inline double GetDirection() { return fDirection; }; // zwrot na torze
|
||||
inline double GetTranslation() { return fCurrentDistance; }; // ABu-030403
|
||||
inline double GetDirection()
|
||||
{
|
||||
return fDirection;
|
||||
}; // zwrot na torze
|
||||
inline double GetTranslation()
|
||||
{
|
||||
return fCurrentDistance;
|
||||
}; // ABu-030403
|
||||
// inline double GetLength(vector3 p1, vector3 cp1, vector3 cp2, vector3 p2)
|
||||
//{ return pCurrentSegment->ComputeLength(p1,cp1,cp2,p2); };
|
||||
// inline double GetRadius(double L, double d); //McZapkie-150503
|
||||
|
||||
12
World.cpp
12
World.cpp
@@ -404,8 +404,9 @@ bool TWorld::Init(HWND NhWnd, HDC hDC)
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR); // Fog Mode
|
||||
WriteLog("glFogfv(GL_FOG_COLOR, FogColor);");
|
||||
glFogfv(GL_FOG_COLOR, FogColor); // Set Fog Color
|
||||
// glFogf(GL_FOG_DENSITY, 0.594f); // How Dense Will The Fog
|
||||
//Be
|
||||
// glFogf(GL_FOG_DENSITY, 0.594f); // How Dense Will The
|
||||
//Fog
|
||||
// Be
|
||||
// glHint(GL_FOG_HINT, GL_NICEST); // Fog Hint Value
|
||||
WriteLog("glFogf(GL_FOG_START, 1000.0f);");
|
||||
glFogf(GL_FOG_START, 10.0f); // Fog Start Depth
|
||||
@@ -1166,7 +1167,7 @@ bool TWorld::Update()
|
||||
double a = fmod(Global::fTimeAngleDeg, 360.0) / 180.0 * M_PI -
|
||||
M_PI; // k¹t godzinny w radianach
|
||||
//(a) jest traktowane jako czas miejscowy, nie uwzglêdniaj¹cy stref czasowych ani czasu
|
||||
//letniego
|
||||
// letniego
|
||||
// aby wyznaczyæ strefê czasow¹, trzeba uwzglêdniæ po³udnik miejscowy
|
||||
// aby uwzglêdniæ czas letni, trzeba sprawdziæ dzieñ roku
|
||||
double L = Global::fLatitudeDeg / 180.0 * M_PI; // szerokoϾ geograficzna
|
||||
@@ -1319,7 +1320,7 @@ bool TWorld::Update()
|
||||
fTimeBuffer -= iter * fMaxDt; // reszta czasu na potem (do bufora)
|
||||
if (n > 20)
|
||||
n = 20; // Ra: je¿eli FPS jest zatrwa¿aj¹co niski, to fizyka nie mo¿e zaj¹æ ca³kowicie
|
||||
// procesora
|
||||
// procesora
|
||||
#if 0
|
||||
Ground.UpdatePhys(fMaxDt,n); //Ra: teraz czas kroku jest (wzglêdnie) sta³y
|
||||
if (DebugModeFlag)
|
||||
@@ -2430,8 +2431,7 @@ bool TWorld::Update()
|
||||
glColor3f(0.0f, 1.0f, 0.0f); // zielone
|
||||
glRasterPos2f(
|
||||
-0.25f,
|
||||
0.18f -
|
||||
0.02f * (i - tmp->Mechanik->iStationStart)); // dopiero
|
||||
0.18f - 0.02f * (i - tmp->Mechanik->iStationStart)); // dopiero
|
||||
// ustawienie
|
||||
// pozycji
|
||||
// ustala
|
||||
|
||||
@@ -49,7 +49,10 @@ void inline vector3::SafeNormalize()
|
||||
}
|
||||
|
||||
// From code in Graphics Gems; p. 766
|
||||
inline scalar_t det2x2(scalar_t a, scalar_t b, scalar_t c, scalar_t d) { return a * d - b * c; }
|
||||
inline scalar_t det2x2(scalar_t a, scalar_t b, scalar_t c, scalar_t d)
|
||||
{
|
||||
return a * d - b * c;
|
||||
}
|
||||
|
||||
inline scalar_t det3x3(scalar_t a1, scalar_t a2, scalar_t a3, scalar_t b1, scalar_t b2, scalar_t b3,
|
||||
scalar_t c1, scalar_t c2, scalar_t c3)
|
||||
@@ -390,7 +393,8 @@ int main(int, char *[])
|
||||
Testmatrix4x4();
|
||||
matrixFailures = failures;
|
||||
|
||||
cout << endl << "****************************************" << endl;
|
||||
cout << endl
|
||||
<< "****************************************" << endl;
|
||||
cout << "* *" << endl;
|
||||
if (vectorFailures + matrixFailures == 0)
|
||||
cout << "* No failures detected in Math3D *" << endl;
|
||||
|
||||
102
dumb3d.h
102
dumb3d.h
@@ -27,15 +27,26 @@ namespace Math3D
|
||||
typedef double scalar_t;
|
||||
// inline pass-throughs to various basic math functions
|
||||
// written in this style to allow for easy substitution with more efficient versions
|
||||
inline scalar_t SINE_FUNCTION(scalar_t x) { return sin(x); }
|
||||
inline scalar_t COSINE_FUNCTION(scalar_t x) { return cos(x); }
|
||||
inline scalar_t SQRT_FUNCTION(scalar_t x) { return sqrt(x); }
|
||||
inline scalar_t SINE_FUNCTION(scalar_t x)
|
||||
{
|
||||
return sin(x);
|
||||
}
|
||||
inline scalar_t COSINE_FUNCTION(scalar_t x)
|
||||
{
|
||||
return cos(x);
|
||||
}
|
||||
inline scalar_t SQRT_FUNCTION(scalar_t x)
|
||||
{
|
||||
return sqrt(x);
|
||||
}
|
||||
|
||||
// 2 element vector
|
||||
class vector2
|
||||
{
|
||||
public:
|
||||
vector2(void) {}
|
||||
vector2(void)
|
||||
{
|
||||
}
|
||||
vector2(scalar_t a, scalar_t b)
|
||||
{
|
||||
x = a;
|
||||
@@ -52,7 +63,9 @@ class vector2
|
||||
class vector3
|
||||
{
|
||||
public:
|
||||
vector3(void) {}
|
||||
vector3(void)
|
||||
{
|
||||
}
|
||||
vector3(scalar_t a, scalar_t b, scalar_t c)
|
||||
{
|
||||
x = a;
|
||||
@@ -71,15 +84,24 @@ class vector3
|
||||
void inline Normalize();
|
||||
void inline SafeNormalize();
|
||||
double inline Length();
|
||||
void inline Zero() { x = y = z = 0.0; };
|
||||
void inline Zero()
|
||||
{
|
||||
x = y = z = 0.0;
|
||||
};
|
||||
|
||||
// [] is to read, () is to write (const correctness)
|
||||
// const scalar_t& operator[] (int i) const { return e[i]; }
|
||||
// scalar_t& operator() (int i) { return e[i]; }
|
||||
|
||||
// Provides access to the underlying array; useful for passing this class off to C APIs
|
||||
const scalar_t *readArray(void) { return &x; }
|
||||
scalar_t *getArray(void) { return &x; }
|
||||
const scalar_t *readArray(void)
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
scalar_t *getArray(void)
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
// union
|
||||
// {
|
||||
@@ -107,7 +129,9 @@ class vector3
|
||||
class matrix4x4
|
||||
{
|
||||
public:
|
||||
matrix4x4(void) {}
|
||||
matrix4x4(void)
|
||||
{
|
||||
}
|
||||
|
||||
// When defining matrices in C arrays, it is easiest to define them with
|
||||
// the column increasing fastest. However, some APIs (OpenGL in particular) do this
|
||||
@@ -130,12 +154,24 @@ class matrix4x4
|
||||
|
||||
// [] is to read, () is to write (const correctness)
|
||||
// m[x][y] or m(x)[y] is the correct form
|
||||
const scalar_t *operator[](int i) const { return &e[i << 2]; }
|
||||
scalar_t *operator()(int i) { return &e[i << 2]; }
|
||||
const scalar_t *operator[](int i) const
|
||||
{
|
||||
return &e[i << 2];
|
||||
}
|
||||
scalar_t *operator()(int i)
|
||||
{
|
||||
return &e[i << 2];
|
||||
}
|
||||
|
||||
// Low-level access to the array.
|
||||
const scalar_t *readArray(void) { return e; }
|
||||
scalar_t *getArray(void) { return e; }
|
||||
const scalar_t *readArray(void)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
scalar_t *getArray(void)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
|
||||
// Construct various matrices; REPLACES CURRENT CONTENTS OF THE MATRIX!
|
||||
// Written this way to work in-place and hence be somewhat more efficient
|
||||
@@ -263,14 +299,20 @@ inline bool operator<(const vector3 &v1, const vector3 &v2)
|
||||
return false;
|
||||
}
|
||||
|
||||
inline vector3 operator-(const vector3 &v) { return vector3(-v.x, -v.y, -v.z); }
|
||||
inline vector3 operator-(const vector3 &v)
|
||||
{
|
||||
return vector3(-v.x, -v.y, -v.z);
|
||||
}
|
||||
|
||||
inline vector3 operator*(const vector3 &v, scalar_t k)
|
||||
{
|
||||
return vector3(k * v.x, k * v.y, k * v.z);
|
||||
}
|
||||
|
||||
inline vector3 operator*(scalar_t k, const vector3 &v) { return v * k; }
|
||||
inline vector3 operator*(scalar_t k, const vector3 &v)
|
||||
{
|
||||
return v * k;
|
||||
}
|
||||
|
||||
inline vector3 &operator*=(vector3 &v, scalar_t k)
|
||||
{
|
||||
@@ -293,11 +335,23 @@ inline vector3 &operator/=(vector3 &v, scalar_t k)
|
||||
return v;
|
||||
}
|
||||
|
||||
inline scalar_t LengthSquared3(const vector3 &v) { return DotProduct(v, v); }
|
||||
inline scalar_t LengthSquared4(const vector3 &v) { return DotProduct4(v, v); }
|
||||
inline scalar_t LengthSquared3(const vector3 &v)
|
||||
{
|
||||
return DotProduct(v, v);
|
||||
}
|
||||
inline scalar_t LengthSquared4(const vector3 &v)
|
||||
{
|
||||
return DotProduct4(v, v);
|
||||
}
|
||||
|
||||
inline scalar_t Length3(const vector3 &v) { return SQRT_FUNCTION(LengthSquared3(v)); }
|
||||
inline scalar_t Length4(const vector3 &v) { return SQRT_FUNCTION(LengthSquared4(v)); }
|
||||
inline scalar_t Length3(const vector3 &v)
|
||||
{
|
||||
return SQRT_FUNCTION(LengthSquared3(v));
|
||||
}
|
||||
inline scalar_t Length4(const vector3 &v)
|
||||
{
|
||||
return SQRT_FUNCTION(LengthSquared4(v));
|
||||
}
|
||||
|
||||
inline vector3 Normalize(const vector3 &v)
|
||||
{
|
||||
@@ -314,7 +368,10 @@ inline vector3 SafeNormalize(const vector3 &v)
|
||||
retVal = v / l;
|
||||
return retVal;
|
||||
}
|
||||
inline vector3 Normalize4(const vector3 &v) { return v / Length4(v); }
|
||||
inline vector3 Normalize4(const vector3 &v)
|
||||
{
|
||||
return v / Length4(v);
|
||||
}
|
||||
|
||||
inline vector3 operator+(const vector3 &v1, const vector3 &v2)
|
||||
{
|
||||
@@ -372,7 +429,10 @@ void inline vector3::Normalize()
|
||||
z *= il;
|
||||
}
|
||||
|
||||
double inline vector3::Length() { return SQRT_FUNCTION(x * x + y * y + z * z); }
|
||||
double inline vector3::Length()
|
||||
{
|
||||
return SQRT_FUNCTION(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
inline bool operator==(const matrix4x4 &m1, const matrix4x4 &m2)
|
||||
{
|
||||
|
||||
25
geometry.cpp
25
geometry.cpp
@@ -11,7 +11,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "Geometry.h"
|
||||
|
||||
inline double sqr(double a) { return (a * a); };
|
||||
inline double sqr(double a)
|
||||
{
|
||||
return (a * a);
|
||||
};
|
||||
|
||||
__fastcall TLine::TLine(){};
|
||||
|
||||
@@ -23,7 +26,10 @@ __fastcall TLine::TLine(vector3 NPoint, vector3 NVector)
|
||||
|
||||
__fastcall TLine::~TLine(){};
|
||||
|
||||
TPlane TLine::GetPlane() { return (TPlane(Point, Vector)); };
|
||||
TPlane TLine::GetPlane()
|
||||
{
|
||||
return (TPlane(Point, Vector));
|
||||
};
|
||||
|
||||
double TLine::GetDistance(vector3 Point1)
|
||||
{
|
||||
@@ -80,11 +86,17 @@ double TPlane::GetSide(vector3 Point)
|
||||
// D3DMath_VectorMatrixMultiply(Vector,src,Transformations);
|
||||
//};
|
||||
|
||||
bool TPlane::Defined() { return !(Vector == vector3(0, 0, 0)); };
|
||||
bool TPlane::Defined()
|
||||
{
|
||||
return !(Vector == vector3(0, 0, 0));
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
inline double Sum(vector3 &Vector) { return (Vector.x + Vector.y + Vector.z); };
|
||||
inline double Sum(vector3 &Vector)
|
||||
{
|
||||
return (Vector.x + Vector.y + Vector.z);
|
||||
};
|
||||
|
||||
bool CrossPoint(vector3 &RetPoint, TLine &Line, TPlane &Plane)
|
||||
{
|
||||
@@ -96,7 +108,10 @@ bool CrossPoint(vector3 &RetPoint, TLine &Line, TPlane &Plane)
|
||||
return (true);
|
||||
};
|
||||
|
||||
inline double GetLength(vector3 &Vector) { return (Vector.Length()); };
|
||||
inline double GetLength(vector3 &Vector)
|
||||
{
|
||||
return (Vector.Length());
|
||||
};
|
||||
|
||||
inline vector3 SetLength(vector3 &Vector, double Length)
|
||||
{
|
||||
|
||||
20
parser.h
20
parser.h
@@ -42,15 +42,27 @@ class cParser : public std::stringstream
|
||||
getTokens();
|
||||
*this >> output;
|
||||
};
|
||||
inline void ignoreToken() { readToken(); };
|
||||
inline void ignoreToken()
|
||||
{
|
||||
readToken();
|
||||
};
|
||||
inline void ignoreTokens(int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
readToken();
|
||||
};
|
||||
inline bool expectToken(std::string value) { return readToken() == value; };
|
||||
bool eof() { return mStream->eof(); };
|
||||
bool ok() { return !mStream->fail(); };
|
||||
inline bool expectToken(std::string value)
|
||||
{
|
||||
return readToken() == value;
|
||||
};
|
||||
bool eof()
|
||||
{
|
||||
return mStream->eof();
|
||||
};
|
||||
bool ok()
|
||||
{
|
||||
return !mStream->fail();
|
||||
};
|
||||
bool getTokens(int Count = 1, bool ToLower = true, const char *Break = "\n\t ;");
|
||||
int getProgress() const; // percentage of file processed.
|
||||
// load traction?
|
||||
|
||||
535
python/include/Python-ast.h
Normal file
535
python/include/Python-ast.h
Normal file
@@ -0,0 +1,535 @@
|
||||
/* File automatically generated by Parser/asdl_c.py. */
|
||||
|
||||
#include "asdl.h"
|
||||
|
||||
typedef struct _mod *mod_ty;
|
||||
|
||||
typedef struct _stmt *stmt_ty;
|
||||
|
||||
typedef struct _expr *expr_ty;
|
||||
|
||||
typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5,
|
||||
Param=6 } expr_context_ty;
|
||||
|
||||
typedef struct _slice *slice_ty;
|
||||
|
||||
typedef enum _boolop { And=1, Or=2 } boolop_ty;
|
||||
|
||||
typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7,
|
||||
RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 }
|
||||
operator_ty;
|
||||
|
||||
typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty;
|
||||
|
||||
typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8,
|
||||
In=9, NotIn=10 } cmpop_ty;
|
||||
|
||||
typedef struct _comprehension *comprehension_ty;
|
||||
|
||||
typedef struct _excepthandler *excepthandler_ty;
|
||||
|
||||
typedef struct _arguments *arguments_ty;
|
||||
|
||||
typedef struct _keyword *keyword_ty;
|
||||
|
||||
typedef struct _alias *alias_ty;
|
||||
|
||||
|
||||
enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
|
||||
Suite_kind=4};
|
||||
struct _mod {
|
||||
enum _mod_kind kind;
|
||||
union {
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
} Module;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
} Interactive;
|
||||
|
||||
struct {
|
||||
expr_ty body;
|
||||
} Expression;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
} Suite;
|
||||
|
||||
} v;
|
||||
};
|
||||
|
||||
enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
|
||||
Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
|
||||
For_kind=8, While_kind=9, If_kind=10, With_kind=11,
|
||||
Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
|
||||
Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
|
||||
Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21,
|
||||
Break_kind=22, Continue_kind=23};
|
||||
struct _stmt {
|
||||
enum _stmt_kind kind;
|
||||
union {
|
||||
struct {
|
||||
identifier name;
|
||||
arguments_ty args;
|
||||
asdl_seq *body;
|
||||
asdl_seq *decorator_list;
|
||||
} FunctionDef;
|
||||
|
||||
struct {
|
||||
identifier name;
|
||||
asdl_seq *bases;
|
||||
asdl_seq *body;
|
||||
asdl_seq *decorator_list;
|
||||
} ClassDef;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Return;
|
||||
|
||||
struct {
|
||||
asdl_seq *targets;
|
||||
} Delete;
|
||||
|
||||
struct {
|
||||
asdl_seq *targets;
|
||||
expr_ty value;
|
||||
} Assign;
|
||||
|
||||
struct {
|
||||
expr_ty target;
|
||||
operator_ty op;
|
||||
expr_ty value;
|
||||
} AugAssign;
|
||||
|
||||
struct {
|
||||
expr_ty dest;
|
||||
asdl_seq *values;
|
||||
bool nl;
|
||||
} Print;
|
||||
|
||||
struct {
|
||||
expr_ty target;
|
||||
expr_ty iter;
|
||||
asdl_seq *body;
|
||||
asdl_seq *orelse;
|
||||
} For;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
asdl_seq *body;
|
||||
asdl_seq *orelse;
|
||||
} While;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
asdl_seq *body;
|
||||
asdl_seq *orelse;
|
||||
} If;
|
||||
|
||||
struct {
|
||||
expr_ty context_expr;
|
||||
expr_ty optional_vars;
|
||||
asdl_seq *body;
|
||||
} With;
|
||||
|
||||
struct {
|
||||
expr_ty type;
|
||||
expr_ty inst;
|
||||
expr_ty tback;
|
||||
} Raise;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
asdl_seq *handlers;
|
||||
asdl_seq *orelse;
|
||||
} TryExcept;
|
||||
|
||||
struct {
|
||||
asdl_seq *body;
|
||||
asdl_seq *finalbody;
|
||||
} TryFinally;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
expr_ty msg;
|
||||
} Assert;
|
||||
|
||||
struct {
|
||||
asdl_seq *names;
|
||||
} Import;
|
||||
|
||||
struct {
|
||||
identifier module;
|
||||
asdl_seq *names;
|
||||
int level;
|
||||
} ImportFrom;
|
||||
|
||||
struct {
|
||||
expr_ty body;
|
||||
expr_ty globals;
|
||||
expr_ty locals;
|
||||
} Exec;
|
||||
|
||||
struct {
|
||||
asdl_seq *names;
|
||||
} Global;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Expr;
|
||||
|
||||
} v;
|
||||
int lineno;
|
||||
int col_offset;
|
||||
};
|
||||
|
||||
enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
|
||||
IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8,
|
||||
SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11,
|
||||
Yield_kind=12, Compare_kind=13, Call_kind=14, Repr_kind=15,
|
||||
Num_kind=16, Str_kind=17, Attribute_kind=18,
|
||||
Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22};
|
||||
struct _expr {
|
||||
enum _expr_kind kind;
|
||||
union {
|
||||
struct {
|
||||
boolop_ty op;
|
||||
asdl_seq *values;
|
||||
} BoolOp;
|
||||
|
||||
struct {
|
||||
expr_ty left;
|
||||
operator_ty op;
|
||||
expr_ty right;
|
||||
} BinOp;
|
||||
|
||||
struct {
|
||||
unaryop_ty op;
|
||||
expr_ty operand;
|
||||
} UnaryOp;
|
||||
|
||||
struct {
|
||||
arguments_ty args;
|
||||
expr_ty body;
|
||||
} Lambda;
|
||||
|
||||
struct {
|
||||
expr_ty test;
|
||||
expr_ty body;
|
||||
expr_ty orelse;
|
||||
} IfExp;
|
||||
|
||||
struct {
|
||||
asdl_seq *keys;
|
||||
asdl_seq *values;
|
||||
} Dict;
|
||||
|
||||
struct {
|
||||
asdl_seq *elts;
|
||||
} Set;
|
||||
|
||||
struct {
|
||||
expr_ty elt;
|
||||
asdl_seq *generators;
|
||||
} ListComp;
|
||||
|
||||
struct {
|
||||
expr_ty elt;
|
||||
asdl_seq *generators;
|
||||
} SetComp;
|
||||
|
||||
struct {
|
||||
expr_ty key;
|
||||
expr_ty value;
|
||||
asdl_seq *generators;
|
||||
} DictComp;
|
||||
|
||||
struct {
|
||||
expr_ty elt;
|
||||
asdl_seq *generators;
|
||||
} GeneratorExp;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Yield;
|
||||
|
||||
struct {
|
||||
expr_ty left;
|
||||
asdl_int_seq *ops;
|
||||
asdl_seq *comparators;
|
||||
} Compare;
|
||||
|
||||
struct {
|
||||
expr_ty func;
|
||||
asdl_seq *args;
|
||||
asdl_seq *keywords;
|
||||
expr_ty starargs;
|
||||
expr_ty kwargs;
|
||||
} Call;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Repr;
|
||||
|
||||
struct {
|
||||
object n;
|
||||
} Num;
|
||||
|
||||
struct {
|
||||
string s;
|
||||
} Str;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
identifier attr;
|
||||
expr_context_ty ctx;
|
||||
} Attribute;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
slice_ty slice;
|
||||
expr_context_ty ctx;
|
||||
} Subscript;
|
||||
|
||||
struct {
|
||||
identifier id;
|
||||
expr_context_ty ctx;
|
||||
} Name;
|
||||
|
||||
struct {
|
||||
asdl_seq *elts;
|
||||
expr_context_ty ctx;
|
||||
} List;
|
||||
|
||||
struct {
|
||||
asdl_seq *elts;
|
||||
expr_context_ty ctx;
|
||||
} Tuple;
|
||||
|
||||
} v;
|
||||
int lineno;
|
||||
int col_offset;
|
||||
};
|
||||
|
||||
enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4};
|
||||
struct _slice {
|
||||
enum _slice_kind kind;
|
||||
union {
|
||||
struct {
|
||||
expr_ty lower;
|
||||
expr_ty upper;
|
||||
expr_ty step;
|
||||
} Slice;
|
||||
|
||||
struct {
|
||||
asdl_seq *dims;
|
||||
} ExtSlice;
|
||||
|
||||
struct {
|
||||
expr_ty value;
|
||||
} Index;
|
||||
|
||||
} v;
|
||||
};
|
||||
|
||||
struct _comprehension {
|
||||
expr_ty target;
|
||||
expr_ty iter;
|
||||
asdl_seq *ifs;
|
||||
};
|
||||
|
||||
enum _excepthandler_kind {ExceptHandler_kind=1};
|
||||
struct _excepthandler {
|
||||
enum _excepthandler_kind kind;
|
||||
union {
|
||||
struct {
|
||||
expr_ty type;
|
||||
expr_ty name;
|
||||
asdl_seq *body;
|
||||
} ExceptHandler;
|
||||
|
||||
} v;
|
||||
int lineno;
|
||||
int col_offset;
|
||||
};
|
||||
|
||||
struct _arguments {
|
||||
asdl_seq *args;
|
||||
identifier vararg;
|
||||
identifier kwarg;
|
||||
asdl_seq *defaults;
|
||||
};
|
||||
|
||||
struct _keyword {
|
||||
identifier arg;
|
||||
expr_ty value;
|
||||
};
|
||||
|
||||
struct _alias {
|
||||
identifier name;
|
||||
identifier asname;
|
||||
};
|
||||
|
||||
|
||||
#define Module(a0, a1) _Py_Module(a0, a1)
|
||||
mod_ty _Py_Module(asdl_seq * body, PyArena *arena);
|
||||
#define Interactive(a0, a1) _Py_Interactive(a0, a1)
|
||||
mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena);
|
||||
#define Expression(a0, a1) _Py_Expression(a0, a1)
|
||||
mod_ty _Py_Expression(expr_ty body, PyArena *arena);
|
||||
#define Suite(a0, a1) _Py_Suite(a0, a1)
|
||||
mod_ty _Py_Suite(asdl_seq * body, PyArena *arena);
|
||||
#define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6)
|
||||
stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
|
||||
asdl_seq * decorator_list, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6)
|
||||
stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body,
|
||||
asdl_seq * decorator_list, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4)
|
||||
stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6)
|
||||
stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq *
|
||||
orelse, int lineno, int col_offset, PyArena *arena);
|
||||
#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
|
||||
int col_offset, PyArena *arena);
|
||||
#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
|
||||
int col_offset, PyArena *arena);
|
||||
#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4)
|
||||
stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4)
|
||||
stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5)
|
||||
stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3)
|
||||
stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2)
|
||||
stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena);
|
||||
#define Break(a0, a1, a2) _Py_Break(a0, a1, a2)
|
||||
stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena);
|
||||
#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2)
|
||||
stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena);
|
||||
#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset,
|
||||
PyArena *arena);
|
||||
#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3)
|
||||
expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena);
|
||||
#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3)
|
||||
expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7)
|
||||
expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
|
||||
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
|
||||
*arena);
|
||||
#define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3)
|
||||
expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena);
|
||||
#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3)
|
||||
expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena);
|
||||
#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3)
|
||||
expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena);
|
||||
#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5)
|
||||
expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
|
||||
lineno, int col_offset, PyArena *arena);
|
||||
#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4)
|
||||
expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int
|
||||
col_offset, PyArena *arena);
|
||||
#define Ellipsis(a0) _Py_Ellipsis(a0)
|
||||
slice_ty _Py_Ellipsis(PyArena *arena);
|
||||
#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3)
|
||||
slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena);
|
||||
#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1)
|
||||
slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena);
|
||||
#define Index(a0, a1) _Py_Index(a0, a1)
|
||||
slice_ty _Py_Index(expr_ty value, PyArena *arena);
|
||||
#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3)
|
||||
comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq *
|
||||
ifs, PyArena *arena);
|
||||
#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5)
|
||||
excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body,
|
||||
int lineno, int col_offset, PyArena *arena);
|
||||
#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4)
|
||||
arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier
|
||||
kwarg, asdl_seq * defaults, PyArena *arena);
|
||||
#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2)
|
||||
keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena);
|
||||
#define alias(a0, a1, a2) _Py_alias(a0, a1, a2)
|
||||
alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena);
|
||||
|
||||
PyObject* PyAST_mod2obj(mod_ty t);
|
||||
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);
|
||||
int PyAST_Check(PyObject* obj);
|
||||
178
python/include/Python.h
Normal file
178
python/include/Python.h
Normal file
@@ -0,0 +1,178 @@
|
||||
#ifndef Py_PYTHON_H
|
||||
#define Py_PYTHON_H
|
||||
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
|
||||
|
||||
/* Include nearly all Python header files */
|
||||
|
||||
#include "patchlevel.h"
|
||||
#include "pyconfig.h"
|
||||
#include "pymacconfig.h"
|
||||
|
||||
/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
|
||||
* old symbol for the benefit of extension modules written before then
|
||||
* that may be conditionalizing on it. The core doesn't use it anymore.
|
||||
*/
|
||||
#ifndef WITH_CYCLE_GC
|
||||
#define WITH_CYCLE_GC 1
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef UCHAR_MAX
|
||||
#error "Something's broken. UCHAR_MAX should be defined in limits.h."
|
||||
#endif
|
||||
|
||||
#if UCHAR_MAX != 255
|
||||
#error "Python's source code assumes C's unsigned char is an 8-bit type."
|
||||
#endif
|
||||
|
||||
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
|
||||
#define _SGI_MP_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef NULL
|
||||
# error "Python.h requires that stdio.h define NULL."
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* For size_t? */
|
||||
#ifdef HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* CAUTION: Build setups should ensure that NDEBUG is defined on the
|
||||
* compiler command line when building Python in release mode; else
|
||||
* assert() calls won't be removed.
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "pyport.h"
|
||||
|
||||
/* pyconfig.h or pyport.h may or may not define DL_IMPORT */
|
||||
#ifndef DL_IMPORT /* declarations for DLL import/export */
|
||||
#define DL_IMPORT(RTYPE) RTYPE
|
||||
#endif
|
||||
#ifndef DL_EXPORT /* declarations for DLL import/export */
|
||||
#define DL_EXPORT(RTYPE) RTYPE
|
||||
#endif
|
||||
|
||||
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
|
||||
* PYMALLOC_DEBUG is in error if pymalloc is not in use.
|
||||
*/
|
||||
#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
|
||||
#define PYMALLOC_DEBUG
|
||||
#endif
|
||||
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
|
||||
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
|
||||
#endif
|
||||
#include "pymath.h"
|
||||
#include "pymem.h"
|
||||
|
||||
#include "object.h"
|
||||
#include "objimpl.h"
|
||||
|
||||
#include "pydebug.h"
|
||||
|
||||
#include "unicodeobject.h"
|
||||
#include "intobject.h"
|
||||
#include "boolobject.h"
|
||||
#include "longobject.h"
|
||||
#include "floatobject.h"
|
||||
#ifndef WITHOUT_COMPLEX
|
||||
#include "complexobject.h"
|
||||
#endif
|
||||
#include "rangeobject.h"
|
||||
#include "stringobject.h"
|
||||
#include "memoryobject.h"
|
||||
#include "bufferobject.h"
|
||||
#include "bytesobject.h"
|
||||
#include "bytearrayobject.h"
|
||||
#include "tupleobject.h"
|
||||
#include "listobject.h"
|
||||
#include "dictobject.h"
|
||||
#include "enumobject.h"
|
||||
#include "setobject.h"
|
||||
#include "methodobject.h"
|
||||
#include "moduleobject.h"
|
||||
#include "funcobject.h"
|
||||
#include "classobject.h"
|
||||
#include "fileobject.h"
|
||||
#include "cobject.h"
|
||||
#include "pycapsule.h"
|
||||
#include "traceback.h"
|
||||
#include "sliceobject.h"
|
||||
#include "cellobject.h"
|
||||
#include "iterobject.h"
|
||||
#include "genobject.h"
|
||||
#include "descrobject.h"
|
||||
#include "warnings.h"
|
||||
#include "weakrefobject.h"
|
||||
|
||||
#include "codecs.h"
|
||||
#include "pyerrors.h"
|
||||
|
||||
#include "pystate.h"
|
||||
|
||||
#include "pyarena.h"
|
||||
#include "modsupport.h"
|
||||
#include "pythonrun.h"
|
||||
#include "ceval.h"
|
||||
#include "sysmodule.h"
|
||||
#include "intrcheck.h"
|
||||
#include "import.h"
|
||||
|
||||
#include "abstract.h"
|
||||
|
||||
#include "compile.h"
|
||||
#include "eval.h"
|
||||
|
||||
#include "pyctype.h"
|
||||
#include "pystrtod.h"
|
||||
#include "pystrcmp.h"
|
||||
#include "dtoa.h"
|
||||
|
||||
/* _Py_Mangle is defined in compile.c */
|
||||
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
||||
|
||||
/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
|
||||
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
|
||||
|
||||
/* PyArg_NoArgs should not be necessary.
|
||||
Set ml_flags in the PyMethodDef to METH_NOARGS. */
|
||||
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
|
||||
|
||||
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
|
||||
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
|
||||
|
||||
#include "pyfpe.h"
|
||||
|
||||
/* These definitions must match corresponding definitions in graminit.h.
|
||||
There's code in compile.c that checks that they are the same. */
|
||||
#define Py_single_input 256
|
||||
#define Py_file_input 257
|
||||
#define Py_eval_input 258
|
||||
|
||||
#ifdef HAVE_PTH
|
||||
/* GNU pth user-space thread support */
|
||||
#include <pth.h>
|
||||
#endif
|
||||
|
||||
/* Define macros for inline documentation. */
|
||||
#define PyDoc_VAR(name) static char name[]
|
||||
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
|
||||
#ifdef WITH_DOC_STRINGS
|
||||
#define PyDoc_STR(str) str
|
||||
#else
|
||||
#define PyDoc_STR(str) ""
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYTHON_H */
|
||||
1396
python/include/abstract.h
Normal file
1396
python/include/abstract.h
Normal file
File diff suppressed because it is too large
Load Diff
45
python/include/asdl.h
Normal file
45
python/include/asdl.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef Py_ASDL_H
|
||||
#define Py_ASDL_H
|
||||
|
||||
typedef PyObject * identifier;
|
||||
typedef PyObject * string;
|
||||
typedef PyObject * object;
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef enum {false, true} bool;
|
||||
#endif
|
||||
|
||||
/* It would be nice if the code generated by asdl_c.py was completely
|
||||
independent of Python, but it is a goal the requires too much work
|
||||
at this stage. So, for example, I'll represent identifiers as
|
||||
interned Python strings.
|
||||
*/
|
||||
|
||||
/* XXX A sequence should be typed so that its use can be typechecked. */
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
void *elements[1];
|
||||
} asdl_seq;
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
int elements[1];
|
||||
} asdl_int_seq;
|
||||
|
||||
asdl_seq *asdl_seq_new(int size, PyArena *arena);
|
||||
asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
|
||||
|
||||
#define asdl_seq_GET(S, I) (S)->elements[(I)]
|
||||
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
|
||||
#ifdef Py_DEBUG
|
||||
#define asdl_seq_SET(S, I, V) { \
|
||||
int _asdl_i = (I); \
|
||||
assert((S) && _asdl_i < (S)->size); \
|
||||
(S)->elements[_asdl_i] = (V); \
|
||||
}
|
||||
#else
|
||||
#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
|
||||
#endif
|
||||
|
||||
#endif /* !Py_ASDL_H */
|
||||
13
python/include/ast.h
Normal file
13
python/include/ast.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef Py_AST_H
|
||||
#define Py_AST_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
|
||||
const char *, PyArena *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_AST_H */
|
||||
32
python/include/bitset.h
Normal file
32
python/include/bitset.h
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
#ifndef Py_BITSET_H
|
||||
#define Py_BITSET_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Bitset interface */
|
||||
|
||||
#define BYTE char
|
||||
|
||||
typedef BYTE *bitset;
|
||||
|
||||
bitset newbitset(int nbits);
|
||||
void delbitset(bitset bs);
|
||||
#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
|
||||
int addbit(bitset bs, int ibit); /* Returns 0 if already set */
|
||||
int samebitset(bitset bs1, bitset bs2, int nbits);
|
||||
void mergebitset(bitset bs1, bitset bs2, int nbits);
|
||||
|
||||
#define BITSPERBYTE (8*sizeof(BYTE))
|
||||
#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
|
||||
|
||||
#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
|
||||
#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
|
||||
#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
|
||||
#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BITSET_H */
|
||||
36
python/include/boolobject.h
Normal file
36
python/include/boolobject.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Boolean object interface */
|
||||
|
||||
#ifndef Py_BOOLOBJECT_H
|
||||
#define Py_BOOLOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef PyIntObject PyBoolObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBool_Type;
|
||||
|
||||
#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
|
||||
|
||||
/* Py_False and Py_True are the only two bools in existence.
|
||||
Don't forget to apply Py_INCREF() when returning either!!! */
|
||||
|
||||
/* Don't use these directly */
|
||||
PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct;
|
||||
|
||||
/* Use these macros */
|
||||
#define Py_False ((PyObject *) &_Py_ZeroStruct)
|
||||
#define Py_True ((PyObject *) &_Py_TrueStruct)
|
||||
|
||||
/* Macros for returning Py_True or Py_False, respectively */
|
||||
#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
|
||||
#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
|
||||
|
||||
/* Function to return a bool from a C long */
|
||||
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BOOLOBJECT_H */
|
||||
33
python/include/bufferobject.h
Normal file
33
python/include/bufferobject.h
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
/* Buffer object interface */
|
||||
|
||||
/* Note: the object's structure is private */
|
||||
|
||||
#ifndef Py_BUFFEROBJECT_H
|
||||
#define Py_BUFFEROBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
|
||||
|
||||
#define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type)
|
||||
|
||||
#define Py_END_OF_BUFFER (-1)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base,
|
||||
Py_ssize_t offset, Py_ssize_t size);
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
|
||||
Py_ssize_t offset,
|
||||
Py_ssize_t size);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size);
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BUFFEROBJECT_H */
|
||||
57
python/include/bytearrayobject.h
Normal file
57
python/include/bytearrayobject.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ByteArray object interface */
|
||||
|
||||
#ifndef Py_BYTEARRAYOBJECT_H
|
||||
#define Py_BYTEARRAYOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Type PyByteArrayObject represents a mutable array of bytes.
|
||||
* The Python API is that of a sequence;
|
||||
* the bytes are mapped to ints in [0, 256).
|
||||
* Bytes are not characters; they may be used to encode characters.
|
||||
* The only way to go between bytes and str/unicode is via encoding
|
||||
* and decoding.
|
||||
* For the convenience of C programmers, the bytes type is considered
|
||||
* to contain a char pointer, not an unsigned char pointer.
|
||||
*/
|
||||
|
||||
/* Object layout */
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
/* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
|
||||
int ob_exports; /* how many buffer exports */
|
||||
Py_ssize_t ob_alloc; /* How many bytes allocated */
|
||||
char *ob_bytes;
|
||||
} PyByteArrayObject;
|
||||
|
||||
/* Type object */
|
||||
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
|
||||
|
||||
/* Type check macros */
|
||||
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
|
||||
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
|
||||
|
||||
/* Direct API functions */
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
|
||||
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
|
||||
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
|
||||
|
||||
/* Macros, trading safety for speed */
|
||||
#define PyByteArray_AS_STRING(self) \
|
||||
(assert(PyByteArray_Check(self)), \
|
||||
Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string)
|
||||
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
|
||||
|
||||
PyAPI_DATA(char) _PyByteArray_empty_string[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BYTEARRAYOBJECT_H */
|
||||
75
python/include/bytes_methods.h
Normal file
75
python/include/bytes_methods.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef Py_BYTES_CTYPE_H
|
||||
#define Py_BYTES_CTYPE_H
|
||||
|
||||
/*
|
||||
* The internal implementation behind PyString (bytes) and PyBytes (buffer)
|
||||
* methods of the given names, they operate on ASCII byte strings.
|
||||
*/
|
||||
extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len);
|
||||
extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
|
||||
|
||||
/* These store their len sized answer in the given preallocated *result arg. */
|
||||
extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
|
||||
extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
|
||||
extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len);
|
||||
extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len);
|
||||
extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len);
|
||||
|
||||
/* Shared __doc__ strings. */
|
||||
extern const char _Py_isspace__doc__[];
|
||||
extern const char _Py_isalpha__doc__[];
|
||||
extern const char _Py_isalnum__doc__[];
|
||||
extern const char _Py_isdigit__doc__[];
|
||||
extern const char _Py_islower__doc__[];
|
||||
extern const char _Py_isupper__doc__[];
|
||||
extern const char _Py_istitle__doc__[];
|
||||
extern const char _Py_lower__doc__[];
|
||||
extern const char _Py_upper__doc__[];
|
||||
extern const char _Py_title__doc__[];
|
||||
extern const char _Py_capitalize__doc__[];
|
||||
extern const char _Py_swapcase__doc__[];
|
||||
|
||||
/* These are left in for backward compatibility and will be removed
|
||||
in 2.8/3.2 */
|
||||
#define ISLOWER(c) Py_ISLOWER(c)
|
||||
#define ISUPPER(c) Py_ISUPPER(c)
|
||||
#define ISALPHA(c) Py_ISALPHA(c)
|
||||
#define ISDIGIT(c) Py_ISDIGIT(c)
|
||||
#define ISXDIGIT(c) Py_ISXDIGIT(c)
|
||||
#define ISALNUM(c) Py_ISALNUM(c)
|
||||
#define ISSPACE(c) Py_ISSPACE(c)
|
||||
|
||||
#undef islower
|
||||
#define islower(c) undefined_islower(c)
|
||||
#undef isupper
|
||||
#define isupper(c) undefined_isupper(c)
|
||||
#undef isalpha
|
||||
#define isalpha(c) undefined_isalpha(c)
|
||||
#undef isdigit
|
||||
#define isdigit(c) undefined_isdigit(c)
|
||||
#undef isxdigit
|
||||
#define isxdigit(c) undefined_isxdigit(c)
|
||||
#undef isalnum
|
||||
#define isalnum(c) undefined_isalnum(c)
|
||||
#undef isspace
|
||||
#define isspace(c) undefined_isspace(c)
|
||||
|
||||
/* These are left in for backward compatibility and will be removed
|
||||
in 2.8/3.2 */
|
||||
#define TOLOWER(c) Py_TOLOWER(c)
|
||||
#define TOUPPER(c) Py_TOUPPER(c)
|
||||
|
||||
#undef tolower
|
||||
#define tolower(c) undefined_tolower(c)
|
||||
#undef toupper
|
||||
#define toupper(c) undefined_toupper(c)
|
||||
|
||||
/* this is needed because some docs are shared from the .o, not static */
|
||||
#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
|
||||
|
||||
#endif /* !Py_BYTES_CTYPE_H */
|
||||
27
python/include/bytesobject.h
Normal file
27
python/include/bytesobject.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#define PyBytesObject PyStringObject
|
||||
#define PyBytes_Type PyString_Type
|
||||
|
||||
#define PyBytes_Check PyString_Check
|
||||
#define PyBytes_CheckExact PyString_CheckExact
|
||||
#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED
|
||||
#define PyBytes_AS_STRING PyString_AS_STRING
|
||||
#define PyBytes_GET_SIZE PyString_GET_SIZE
|
||||
#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS
|
||||
|
||||
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
|
||||
#define PyBytes_FromString PyString_FromString
|
||||
#define PyBytes_FromFormatV PyString_FromFormatV
|
||||
#define PyBytes_FromFormat PyString_FromFormat
|
||||
#define PyBytes_Size PyString_Size
|
||||
#define PyBytes_AsString PyString_AsString
|
||||
#define PyBytes_Repr PyString_Repr
|
||||
#define PyBytes_Concat PyString_Concat
|
||||
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
|
||||
#define _PyBytes_Resize _PyString_Resize
|
||||
#define _PyBytes_Eq _PyString_Eq
|
||||
#define PyBytes_Format PyString_Format
|
||||
#define _PyBytes_FormatLong _PyString_FormatLong
|
||||
#define PyBytes_DecodeEscape PyString_DecodeEscape
|
||||
#define _PyBytes_Join _PyString_Join
|
||||
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
|
||||
#define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping
|
||||
73
python/include/cStringIO.h
Normal file
73
python/include/cStringIO.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef Py_CSTRINGIO_H
|
||||
#define Py_CSTRINGIO_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
|
||||
This header provides access to cStringIO objects from C.
|
||||
Functions are provided for calling cStringIO objects and
|
||||
macros are provided for testing whether you have cStringIO
|
||||
objects.
|
||||
|
||||
Before calling any of the functions or macros, you must initialize
|
||||
the routines with:
|
||||
|
||||
PycString_IMPORT
|
||||
|
||||
This would typically be done in your init function.
|
||||
|
||||
*/
|
||||
|
||||
#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI"
|
||||
|
||||
#define PycString_IMPORT \
|
||||
PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\
|
||||
PycStringIO_CAPSULE_NAME, 0))
|
||||
|
||||
/* Basic functions to manipulate cStringIO objects from C */
|
||||
|
||||
static struct PycStringIO_CAPI {
|
||||
|
||||
/* Read a string from an input object. If the last argument
|
||||
is -1, the remainder will be read.
|
||||
*/
|
||||
int(*cread)(PyObject *, char **, Py_ssize_t);
|
||||
|
||||
/* Read a line from an input object. Returns the length of the read
|
||||
line as an int and a pointer inside the object buffer as char** (so
|
||||
the caller doesn't have to provide its own buffer as destination).
|
||||
*/
|
||||
int(*creadline)(PyObject *, char **);
|
||||
|
||||
/* Write a string to an output object*/
|
||||
int(*cwrite)(PyObject *, const char *, Py_ssize_t);
|
||||
|
||||
/* Get the output object as a Python string (returns new reference). */
|
||||
PyObject *(*cgetvalue)(PyObject *);
|
||||
|
||||
/* Create a new output object */
|
||||
PyObject *(*NewOutput)(int);
|
||||
|
||||
/* Create an input object from a Python string
|
||||
(copies the Python string reference).
|
||||
*/
|
||||
PyObject *(*NewInput)(PyObject *);
|
||||
|
||||
/* The Python types for cStringIO input and output objects.
|
||||
Note that you can do input on an output object.
|
||||
*/
|
||||
PyTypeObject *InputType, *OutputType;
|
||||
|
||||
} *PycStringIO;
|
||||
|
||||
/* These can be used to test if you have one */
|
||||
#define PycStringIO_InputCheck(O) \
|
||||
(Py_TYPE(O)==PycStringIO->InputType)
|
||||
#define PycStringIO_OutputCheck(O) \
|
||||
(Py_TYPE(O)==PycStringIO->OutputType)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CSTRINGIO_H */
|
||||
28
python/include/cellobject.h
Normal file
28
python/include/cellobject.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Cell object interface */
|
||||
|
||||
#ifndef Py_CELLOBJECT_H
|
||||
#define Py_CELLOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *ob_ref; /* Content of the cell or NULL when empty */
|
||||
} PyCellObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCell_Type;
|
||||
|
||||
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
|
||||
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
|
||||
|
||||
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
|
||||
#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_TUPLEOBJECT_H */
|
||||
153
python/include/ceval.h
Normal file
153
python/include/ceval.h
Normal file
@@ -0,0 +1,153 @@
|
||||
#ifndef Py_CEVAL_H
|
||||
#define Py_CEVAL_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Interface to random parts in ceval.c */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
|
||||
PyObject *, PyObject *, PyObject *);
|
||||
|
||||
/* Inline this */
|
||||
#define PyEval_CallObject(func,arg) \
|
||||
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
|
||||
const char *format, ...);
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
|
||||
const char *methodname,
|
||||
const char *format, ...);
|
||||
|
||||
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
|
||||
PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
|
||||
PyAPI_FUNC(int) PyEval_GetRestricted(void);
|
||||
|
||||
/* Look at the current frame's (if any) code's co_flags, and turn on
|
||||
the corresponding compiler flags in cf->cf_flags. Return 1 if any
|
||||
flag was set, else return 0. */
|
||||
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
|
||||
|
||||
PyAPI_FUNC(int) Py_FlushLine(void);
|
||||
|
||||
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
|
||||
PyAPI_FUNC(int) Py_MakePendingCalls(void);
|
||||
|
||||
/* Protection against deeply nested recursive calls */
|
||||
PyAPI_FUNC(void) Py_SetRecursionLimit(int);
|
||||
PyAPI_FUNC(int) Py_GetRecursionLimit(void);
|
||||
|
||||
#define Py_EnterRecursiveCall(where) \
|
||||
(_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
|
||||
_Py_CheckRecursiveCall(where))
|
||||
#define Py_LeaveRecursiveCall() \
|
||||
(--PyThreadState_GET()->recursion_depth)
|
||||
PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where);
|
||||
PyAPI_DATA(int) _Py_CheckRecursionLimit;
|
||||
#ifdef USE_STACKCHECK
|
||||
# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit)
|
||||
#else
|
||||
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
|
||||
|
||||
/* this used to be handled on a per-thread basis - now just two globals */
|
||||
PyAPI_DATA(volatile int) _Py_Ticker;
|
||||
PyAPI_DATA(int) _Py_CheckInterval;
|
||||
|
||||
/* Interface for threads.
|
||||
|
||||
A module that plans to do a blocking system call (or something else
|
||||
that lasts a long time and doesn't touch Python data) can allow other
|
||||
threads to run as follows:
|
||||
|
||||
...preparations here...
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
...blocking system call here...
|
||||
Py_END_ALLOW_THREADS
|
||||
...interpret result here...
|
||||
|
||||
The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
|
||||
{}-surrounded block.
|
||||
To leave the block in the middle (e.g., with return), you must insert
|
||||
a line containing Py_BLOCK_THREADS before the return, e.g.
|
||||
|
||||
if (...premature_exit...) {
|
||||
Py_BLOCK_THREADS
|
||||
PyErr_SetFromErrno(PyExc_IOError);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
An alternative is:
|
||||
|
||||
Py_BLOCK_THREADS
|
||||
if (...premature_exit...) {
|
||||
PyErr_SetFromErrno(PyExc_IOError);
|
||||
return NULL;
|
||||
}
|
||||
Py_UNBLOCK_THREADS
|
||||
|
||||
For convenience, that the value of 'errno' is restored across
|
||||
Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
|
||||
|
||||
WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
|
||||
Py_END_ALLOW_THREADS!!!
|
||||
|
||||
The function PyEval_InitThreads() should be called only from
|
||||
initthread() in "threadmodule.c".
|
||||
|
||||
Note that not yet all candidates have been converted to use this
|
||||
mechanism!
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
|
||||
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
|
||||
PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
|
||||
PyAPI_FUNC(void) PyEval_InitThreads(void);
|
||||
PyAPI_FUNC(void) PyEval_AcquireLock(void);
|
||||
PyAPI_FUNC(void) PyEval_ReleaseLock(void);
|
||||
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
|
||||
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
|
||||
PyAPI_FUNC(void) PyEval_ReInitThreads(void);
|
||||
|
||||
#define Py_BEGIN_ALLOW_THREADS { \
|
||||
PyThreadState *_save; \
|
||||
_save = PyEval_SaveThread();
|
||||
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
|
||||
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
|
||||
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
|
||||
}
|
||||
|
||||
#else /* !WITH_THREAD */
|
||||
|
||||
#define Py_BEGIN_ALLOW_THREADS {
|
||||
#define Py_BLOCK_THREADS
|
||||
#define Py_UNBLOCK_THREADS
|
||||
#define Py_END_ALLOW_THREADS }
|
||||
|
||||
#endif /* !WITH_THREAD */
|
||||
|
||||
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CEVAL_H */
|
||||
83
python/include/classobject.h
Normal file
83
python/include/classobject.h
Normal file
@@ -0,0 +1,83 @@
|
||||
|
||||
/* Class object interface */
|
||||
|
||||
/* Revealing some structures (not for general use) */
|
||||
|
||||
#ifndef Py_CLASSOBJECT_H
|
||||
#define Py_CLASSOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *cl_bases; /* A tuple of class objects */
|
||||
PyObject *cl_dict; /* A dictionary */
|
||||
PyObject *cl_name; /* A string */
|
||||
/* The following three are functions or NULL */
|
||||
PyObject *cl_getattr;
|
||||
PyObject *cl_setattr;
|
||||
PyObject *cl_delattr;
|
||||
PyObject *cl_weakreflist; /* List of weak references */
|
||||
} PyClassObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyClassObject *in_class; /* The class object */
|
||||
PyObject *in_dict; /* A dictionary */
|
||||
PyObject *in_weakreflist; /* List of weak references */
|
||||
} PyInstanceObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *im_func; /* The callable object implementing the method */
|
||||
PyObject *im_self; /* The instance it is bound to, or NULL */
|
||||
PyObject *im_class; /* The class that asked for the method */
|
||||
PyObject *im_weakreflist; /* List of weak references */
|
||||
} PyMethodObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
|
||||
|
||||
#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
|
||||
#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
|
||||
#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *,
|
||||
PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *);
|
||||
|
||||
/* Look up attribute with name (a string) on instance object pinst, using
|
||||
* only the instance and base class dicts. If a descriptor is found in
|
||||
* a class dict, the descriptor is returned without calling it.
|
||||
* Returns NULL if nothing found, else a borrowed reference to the
|
||||
* value associated with name in the dict in which name was found.
|
||||
* The point of this routine is that it never calls arbitrary Python
|
||||
* code, so is always "safe": all it does is dict lookups. The function
|
||||
* can't fail, never sets an exception, and NULL is not an error (it just
|
||||
* means "not found").
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
#define PyMethod_GET_FUNCTION(meth) \
|
||||
(((PyMethodObject *)meth) -> im_func)
|
||||
#define PyMethod_GET_SELF(meth) \
|
||||
(((PyMethodObject *)meth) -> im_self)
|
||||
#define PyMethod_GET_CLASS(meth) \
|
||||
(((PyMethodObject *)meth) -> im_class)
|
||||
|
||||
PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CLASSOBJECT_H */
|
||||
89
python/include/cobject.h
Normal file
89
python/include/cobject.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
CObjects are marked Pending Deprecation as of Python 2.7.
|
||||
The full schedule for 2.x is as follows:
|
||||
- CObjects are marked Pending Deprecation in Python 2.7.
|
||||
- CObjects will be marked Deprecated in Python 2.8
|
||||
(if there is one).
|
||||
- CObjects will be removed in Python 2.9 (if there is one).
|
||||
|
||||
Additionally, for the Python 3.x series:
|
||||
- CObjects were marked Deprecated in Python 3.1.
|
||||
- CObjects will be removed in Python 3.2.
|
||||
|
||||
You should switch all use of CObjects to capsules. Capsules
|
||||
have a safer and more consistent API. For more information,
|
||||
see Include/pycapsule.h, or read the "Capsules" topic in
|
||||
the "Python/C API Reference Manual".
|
||||
|
||||
Python 2.7 no longer uses CObjects itself; all objects which
|
||||
were formerly CObjects are now capsules. Note that this change
|
||||
does not by itself break binary compatibility with extensions
|
||||
built for previous versions of Python--PyCObject_AsVoidPtr()
|
||||
has been changed to also understand capsules.
|
||||
|
||||
*/
|
||||
|
||||
/* original file header comment follows: */
|
||||
|
||||
/* C objects to be exported from one extension module to another.
|
||||
|
||||
C objects are used for communication between extension modules.
|
||||
They provide a way for an extension module to export a C interface
|
||||
to other extension modules, so that extension modules can use the
|
||||
Python import mechanism to link to one another.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef Py_COBJECT_H
|
||||
#define Py_COBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCObject_Type;
|
||||
|
||||
#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type)
|
||||
|
||||
/* Create a PyCObject from a pointer to a C object and an optional
|
||||
destructor function. If the second argument is non-null, then it
|
||||
will be called with the first argument if and when the PyCObject is
|
||||
destroyed.
|
||||
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr(
|
||||
void *cobj, void (*destruct)(void*));
|
||||
|
||||
|
||||
/* Create a PyCObject from a pointer to a C object, a description object,
|
||||
and an optional destructor function. If the third argument is non-null,
|
||||
then it will be called with the first and second arguments if and when
|
||||
the PyCObject is destroyed.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc(
|
||||
void *cobj, void *desc, void (*destruct)(void*,void*));
|
||||
|
||||
/* Retrieve a pointer to a C object from a PyCObject. */
|
||||
PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *);
|
||||
|
||||
/* Retrieve a pointer to a description object from a PyCObject. */
|
||||
PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *);
|
||||
|
||||
/* Import a pointer to a C object from a module using a PyCObject. */
|
||||
PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name);
|
||||
|
||||
/* Modify a C object. Fails (==0) if object has a destructor. */
|
||||
PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj);
|
||||
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
void *cobject;
|
||||
void *desc;
|
||||
void (*destructor)(void *);
|
||||
} PyCObject;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COBJECT_H */
|
||||
107
python/include/code.h
Normal file
107
python/include/code.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/* Definitions for bytecode */
|
||||
|
||||
#ifndef Py_CODE_H
|
||||
#define Py_CODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Bytecode object */
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
int co_argcount; /* #arguments, except *args */
|
||||
int co_nlocals; /* #local variables */
|
||||
int co_stacksize; /* #entries needed for evaluation stack */
|
||||
int co_flags; /* CO_..., see below */
|
||||
PyObject *co_code; /* instruction opcodes */
|
||||
PyObject *co_consts; /* list (constants used) */
|
||||
PyObject *co_names; /* list of strings (names used) */
|
||||
PyObject *co_varnames; /* tuple of strings (local variable names) */
|
||||
PyObject *co_freevars; /* tuple of strings (free variable names) */
|
||||
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
|
||||
/* The rest doesn't count for hash/cmp */
|
||||
PyObject *co_filename; /* string (where it was loaded from) */
|
||||
PyObject *co_name; /* string (name, for reference) */
|
||||
int co_firstlineno; /* first source line number */
|
||||
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
|
||||
Objects/lnotab_notes.txt for details. */
|
||||
void *co_zombieframe; /* for optimization only (see frameobject.c) */
|
||||
PyObject *co_weakreflist; /* to support weakrefs to code objects */
|
||||
} PyCodeObject;
|
||||
|
||||
/* Masks for co_flags above */
|
||||
#define CO_OPTIMIZED 0x0001
|
||||
#define CO_NEWLOCALS 0x0002
|
||||
#define CO_VARARGS 0x0004
|
||||
#define CO_VARKEYWORDS 0x0008
|
||||
#define CO_NESTED 0x0010
|
||||
#define CO_GENERATOR 0x0020
|
||||
/* The CO_NOFREE flag is set if there are no free or cell variables.
|
||||
This information is redundant, but it allows a single flag test
|
||||
to determine whether there is any extra work to be done when the
|
||||
call frame it setup.
|
||||
*/
|
||||
#define CO_NOFREE 0x0040
|
||||
|
||||
#if 0
|
||||
/* This is no longer used. Stopped defining in 2.5, do not re-use. */
|
||||
#define CO_GENERATOR_ALLOWED 0x1000
|
||||
#endif
|
||||
#define CO_FUTURE_DIVISION 0x2000
|
||||
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
|
||||
#define CO_FUTURE_WITH_STATEMENT 0x8000
|
||||
#define CO_FUTURE_PRINT_FUNCTION 0x10000
|
||||
#define CO_FUTURE_UNICODE_LITERALS 0x20000
|
||||
|
||||
/* This should be defined if a future statement modifies the syntax.
|
||||
For example, when a keyword is added.
|
||||
*/
|
||||
#if 1
|
||||
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
|
||||
#endif
|
||||
|
||||
#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCode_Type;
|
||||
|
||||
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
|
||||
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
|
||||
|
||||
/* Public interface */
|
||||
PyAPI_FUNC(PyCodeObject *) PyCode_New(
|
||||
int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *);
|
||||
/* same as struct above */
|
||||
|
||||
/* Creates a new empty code object with the specified source location. */
|
||||
PyAPI_FUNC(PyCodeObject *)
|
||||
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno);
|
||||
|
||||
/* Return the line number associated with the specified bytecode index
|
||||
in this code object. If you just need the line number of a frame,
|
||||
use PyFrame_GetLineNumber() instead. */
|
||||
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
|
||||
|
||||
/* for internal use only */
|
||||
#define _PyCode_GETCODEPTR(co, pp) \
|
||||
((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
|
||||
((co)->co_code, 0, (void **)(pp)))
|
||||
|
||||
typedef struct _addr_pair {
|
||||
int ap_lower;
|
||||
int ap_upper;
|
||||
} PyAddrPair;
|
||||
|
||||
/* Update *bounds to describe the first and one-past-the-last instructions in the
|
||||
same line as lasti. Return the number of that line.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
|
||||
int lasti, PyAddrPair *bounds);
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
|
||||
PyObject *names, PyObject *lineno_obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CODE_H */
|
||||
167
python/include/codecs.h
Normal file
167
python/include/codecs.h
Normal file
@@ -0,0 +1,167 @@
|
||||
#ifndef Py_CODECREGISTRY_H
|
||||
#define Py_CODECREGISTRY_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
||||
Python Codec Registry and support functions
|
||||
|
||||
|
||||
Written by Marc-Andre Lemburg (mal@lemburg.com).
|
||||
|
||||
Copyright (c) Corporation for National Research Initiatives.
|
||||
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
/* Register a new codec search function.
|
||||
|
||||
As side effect, this tries to load the encodings package, if not
|
||||
yet done, to make sure that it is always first in the list of
|
||||
search functions.
|
||||
|
||||
The search_function's refcount is incremented by this function. */
|
||||
|
||||
PyAPI_FUNC(int) PyCodec_Register(
|
||||
PyObject *search_function
|
||||
);
|
||||
|
||||
/* Codec register lookup API.
|
||||
|
||||
Looks up the given encoding and returns a CodecInfo object with
|
||||
function attributes which implement the different aspects of
|
||||
processing the encoding.
|
||||
|
||||
The encoding string is looked up converted to all lower-case
|
||||
characters. This makes encodings looked up through this mechanism
|
||||
effectively case-insensitive.
|
||||
|
||||
If no codec is found, a KeyError is set and NULL returned.
|
||||
|
||||
As side effect, this tries to load the encodings package, if not
|
||||
yet done. This is part of the lazy load strategy for the encodings
|
||||
package.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Generic codec based encoding API.
|
||||
|
||||
object is passed through the encoder function found for the given
|
||||
encoding using the error handling method defined by errors. errors
|
||||
may be NULL to use the default method defined for the codec.
|
||||
|
||||
Raises a LookupError in case no encoder can be found.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Generic codec based decoding API.
|
||||
|
||||
object is passed through the decoder function found for the given
|
||||
encoding using the error handling method defined by errors. errors
|
||||
may be NULL to use the default method defined for the codec.
|
||||
|
||||
Raises a LookupError in case no encoder can be found.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* --- Codec Lookup APIs --------------------------------------------------
|
||||
|
||||
All APIs return a codec object with incremented refcount and are
|
||||
based on _PyCodec_Lookup(). The same comments w/r to the encoding
|
||||
name also apply to these APIs.
|
||||
|
||||
*/
|
||||
|
||||
/* Get an encoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get a decoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get a IncrementalEncoder object for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a IncrementalDecoder object function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a StreamReader factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a StreamWriter factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Unicode encoding error handling callback registry API */
|
||||
|
||||
/* Register the error handling callback function error under the given
|
||||
name. This function will be called by the codec when it encounters
|
||||
unencodable characters/undecodable bytes and doesn't know the
|
||||
callback name, when name is specified as the error parameter
|
||||
in the call to the encode/decode function.
|
||||
Return 0 on success, -1 on error */
|
||||
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
|
||||
|
||||
/* Lookup the error handling callback function registered under the given
|
||||
name. As a special case NULL can be passed, in which case
|
||||
the error handling callback for "strict" will be returned. */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
|
||||
|
||||
/* raise exc as an exception */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
|
||||
|
||||
/* ignore the unicode error, skipping the faulty input */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with ? or U+FFFD */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with XML character references */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with backslash escapes (\x, \u and \U) */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CODECREGISTRY_H */
|
||||
40
python/include/compile.h
Normal file
40
python/include/compile.h
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#ifndef Py_COMPILE_H
|
||||
#define Py_COMPILE_H
|
||||
|
||||
#include "code.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Public interface */
|
||||
struct _node; /* Declare the existence of this type */
|
||||
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
|
||||
|
||||
/* Future feature support */
|
||||
|
||||
typedef struct {
|
||||
int ff_features; /* flags set by future statements */
|
||||
int ff_lineno; /* line number of last future statement */
|
||||
} PyFutureFeatures;
|
||||
|
||||
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
||||
#define FUTURE_GENERATORS "generators"
|
||||
#define FUTURE_DIVISION "division"
|
||||
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
|
||||
#define FUTURE_WITH_STATEMENT "with_statement"
|
||||
#define FUTURE_PRINT_FUNCTION "print_function"
|
||||
#define FUTURE_UNICODE_LITERALS "unicode_literals"
|
||||
|
||||
|
||||
struct _mod; /* Declare the existence of this type */
|
||||
PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
|
||||
PyCompilerFlags *, PyArena *);
|
||||
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COMPILE_H */
|
||||
66
python/include/complexobject.h
Normal file
66
python/include/complexobject.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* Complex number structure */
|
||||
|
||||
#ifndef Py_COMPLEXOBJECT_H
|
||||
#define Py_COMPLEXOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
double real;
|
||||
double imag;
|
||||
} Py_complex;
|
||||
|
||||
/* Operations on complex numbers from complexmodule.c */
|
||||
|
||||
#define c_sum _Py_c_sum
|
||||
#define c_diff _Py_c_diff
|
||||
#define c_neg _Py_c_neg
|
||||
#define c_prod _Py_c_prod
|
||||
#define c_quot _Py_c_quot
|
||||
#define c_pow _Py_c_pow
|
||||
#define c_abs _Py_c_abs
|
||||
|
||||
PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_neg(Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(double) c_abs(Py_complex);
|
||||
|
||||
|
||||
/* Complex object interface */
|
||||
|
||||
/*
|
||||
PyComplexObject represents a complex number with double-precision
|
||||
real and imaginary parts.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Py_complex cval;
|
||||
} PyComplexObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyComplex_Type;
|
||||
|
||||
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
|
||||
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
|
||||
|
||||
PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
|
||||
PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
|
||||
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
|
||||
char *format_spec,
|
||||
Py_ssize_t format_spec_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COMPLEXOBJECT_H */
|
||||
239
python/include/datetime.h
Normal file
239
python/include/datetime.h
Normal file
@@ -0,0 +1,239 @@
|
||||
/* datetime.h
|
||||
*/
|
||||
|
||||
#ifndef DATETIME_H
|
||||
#define DATETIME_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Fields are packed into successive bytes, each viewed as unsigned and
|
||||
* big-endian, unless otherwise noted:
|
||||
*
|
||||
* byte offset
|
||||
* 0 year 2 bytes, 1-9999
|
||||
* 2 month 1 byte, 1-12
|
||||
* 3 day 1 byte, 1-31
|
||||
* 4 hour 1 byte, 0-23
|
||||
* 5 minute 1 byte, 0-59
|
||||
* 6 second 1 byte, 0-59
|
||||
* 7 usecond 3 bytes, 0-999999
|
||||
* 10
|
||||
*/
|
||||
|
||||
/* # of bytes for year, month, and day. */
|
||||
#define _PyDateTime_DATE_DATASIZE 4
|
||||
|
||||
/* # of bytes for hour, minute, second, and usecond. */
|
||||
#define _PyDateTime_TIME_DATASIZE 6
|
||||
|
||||
/* # of bytes for year, month, day, hour, minute, second, and usecond. */
|
||||
#define _PyDateTime_DATETIME_DATASIZE 10
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD
|
||||
long hashcode; /* -1 when unknown */
|
||||
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
|
||||
int seconds; /* 0 <= seconds < 24*3600 is invariant */
|
||||
int microseconds; /* 0 <= microseconds < 1000000 is invariant */
|
||||
} PyDateTime_Delta;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD /* a pure abstract base clase */
|
||||
} PyDateTime_TZInfo;
|
||||
|
||||
|
||||
/* The datetime and time types have hashcodes, and an optional tzinfo member,
|
||||
* present if and only if hastzinfo is true.
|
||||
*/
|
||||
#define _PyTZINFO_HEAD \
|
||||
PyObject_HEAD \
|
||||
long hashcode; \
|
||||
char hastzinfo; /* boolean flag */
|
||||
|
||||
/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
|
||||
* convenient to cast to, when getting at the hastzinfo member of objects
|
||||
* starting with _PyTZINFO_HEAD.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
_PyTZINFO_HEAD
|
||||
} _PyDateTime_BaseTZInfo;
|
||||
|
||||
/* All time objects are of PyDateTime_TimeType, but that can be allocated
|
||||
* in two ways, with or without a tzinfo member. Without is the same as
|
||||
* tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an
|
||||
* internal struct used to allocate the right amount of space for the
|
||||
* "without" case.
|
||||
*/
|
||||
#define _PyDateTime_TIMEHEAD \
|
||||
_PyTZINFO_HEAD \
|
||||
unsigned char data[_PyDateTime_TIME_DATASIZE];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_TIMEHEAD
|
||||
} _PyDateTime_BaseTime; /* hastzinfo false */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_TIMEHEAD
|
||||
PyObject *tzinfo;
|
||||
} PyDateTime_Time; /* hastzinfo true */
|
||||
|
||||
|
||||
/* All datetime objects are of PyDateTime_DateTimeType, but that can be
|
||||
* allocated in two ways too, just like for time objects above. In addition,
|
||||
* the plain date type is a base class for datetime, so it must also have
|
||||
* a hastzinfo member (although it's unused there).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
_PyTZINFO_HEAD
|
||||
unsigned char data[_PyDateTime_DATE_DATASIZE];
|
||||
} PyDateTime_Date;
|
||||
|
||||
#define _PyDateTime_DATETIMEHEAD \
|
||||
_PyTZINFO_HEAD \
|
||||
unsigned char data[_PyDateTime_DATETIME_DATASIZE];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_DATETIMEHEAD
|
||||
} _PyDateTime_BaseDateTime; /* hastzinfo false */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_DATETIMEHEAD
|
||||
PyObject *tzinfo;
|
||||
} PyDateTime_DateTime; /* hastzinfo true */
|
||||
|
||||
|
||||
/* Apply for date and datetime instances. */
|
||||
#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \
|
||||
((PyDateTime_Date*)o)->data[1])
|
||||
#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2])
|
||||
#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3])
|
||||
|
||||
#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4])
|
||||
#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5])
|
||||
#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6])
|
||||
#define PyDateTime_DATE_GET_MICROSECOND(o) \
|
||||
((((PyDateTime_DateTime*)o)->data[7] << 16) | \
|
||||
(((PyDateTime_DateTime*)o)->data[8] << 8) | \
|
||||
((PyDateTime_DateTime*)o)->data[9])
|
||||
|
||||
/* Apply for time instances. */
|
||||
#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0])
|
||||
#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1])
|
||||
#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2])
|
||||
#define PyDateTime_TIME_GET_MICROSECOND(o) \
|
||||
((((PyDateTime_Time*)o)->data[3] << 16) | \
|
||||
(((PyDateTime_Time*)o)->data[4] << 8) | \
|
||||
((PyDateTime_Time*)o)->data[5])
|
||||
|
||||
|
||||
/* Define structure for C API. */
|
||||
typedef struct {
|
||||
/* type objects */
|
||||
PyTypeObject *DateType;
|
||||
PyTypeObject *DateTimeType;
|
||||
PyTypeObject *TimeType;
|
||||
PyTypeObject *DeltaType;
|
||||
PyTypeObject *TZInfoType;
|
||||
|
||||
/* constructors */
|
||||
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
|
||||
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
|
||||
PyObject*, PyTypeObject*);
|
||||
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
|
||||
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
|
||||
|
||||
/* constructors for the DB API */
|
||||
PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
|
||||
PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
|
||||
|
||||
} PyDateTime_CAPI;
|
||||
|
||||
#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
|
||||
|
||||
|
||||
/* "magic" constant used to partially protect against developer mistakes. */
|
||||
#define DATETIME_API_MAGIC 0x414548d5
|
||||
|
||||
#ifdef Py_BUILD_CORE
|
||||
|
||||
/* Macros for type checking when building the Python core. */
|
||||
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
|
||||
#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)
|
||||
|
||||
#else
|
||||
|
||||
/* Define global variable for the C API and a macro for setting it. */
|
||||
static PyDateTime_CAPI *PyDateTimeAPI = NULL;
|
||||
|
||||
#define PyDateTime_IMPORT \
|
||||
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
|
||||
|
||||
/* Macros for type checking when not building the Python core. */
|
||||
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
|
||||
#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType)
|
||||
|
||||
/* Macros for accessing constructors in a simplified fashion. */
|
||||
#define PyDate_FromDate(year, month, day) \
|
||||
PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
|
||||
PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \
|
||||
min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_FromTime(hour, minute, second, usecond) \
|
||||
PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \
|
||||
Py_None, PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_FromDSU(days, seconds, useconds) \
|
||||
PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \
|
||||
PyDateTimeAPI->DeltaType)
|
||||
|
||||
/* Macros supporting the DB API. */
|
||||
#define PyDateTime_FromTimestamp(args) \
|
||||
PyDateTimeAPI->DateTime_FromTimestamp( \
|
||||
(PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)
|
||||
|
||||
#define PyDate_FromTimestamp(args) \
|
||||
PyDateTimeAPI->Date_FromTimestamp( \
|
||||
(PyObject*) (PyDateTimeAPI->DateType), args)
|
||||
|
||||
#endif /* Py_BUILD_CORE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
94
python/include/descrobject.h
Normal file
94
python/include/descrobject.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* Descriptors */
|
||||
#ifndef Py_DESCROBJECT_H
|
||||
#define Py_DESCROBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef PyObject *(*getter)(PyObject *, void *);
|
||||
typedef int (*setter)(PyObject *, PyObject *, void *);
|
||||
|
||||
typedef struct PyGetSetDef {
|
||||
char *name;
|
||||
getter get;
|
||||
setter set;
|
||||
char *doc;
|
||||
void *closure;
|
||||
} PyGetSetDef;
|
||||
|
||||
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
|
||||
void *wrapped);
|
||||
|
||||
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
|
||||
void *wrapped, PyObject *kwds);
|
||||
|
||||
struct wrapperbase {
|
||||
char *name;
|
||||
int offset;
|
||||
void *function;
|
||||
wrapperfunc wrapper;
|
||||
char *doc;
|
||||
int flags;
|
||||
PyObject *name_strobj;
|
||||
};
|
||||
|
||||
/* Flags for above struct */
|
||||
#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
|
||||
|
||||
/* Various kinds of descriptor objects */
|
||||
|
||||
#define PyDescr_COMMON \
|
||||
PyObject_HEAD \
|
||||
PyTypeObject *d_type; \
|
||||
PyObject *d_name
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
} PyDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
PyMethodDef *d_method;
|
||||
} PyMethodDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
struct PyMemberDef *d_member;
|
||||
} PyMemberDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
PyGetSetDef *d_getset;
|
||||
} PyGetSetDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
struct wrapperbase *d_base;
|
||||
void *d_wrapped; /* This can be any function pointer */
|
||||
} PyWrapperDescrObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
|
||||
struct PyMemberDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
|
||||
struct PyGetSetDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
|
||||
struct wrapperbase *, void *);
|
||||
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
||||
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyProperty_Type;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_DESCROBJECT_H */
|
||||
|
||||
156
python/include/dictobject.h
Normal file
156
python/include/dictobject.h
Normal file
@@ -0,0 +1,156 @@
|
||||
#ifndef Py_DICTOBJECT_H
|
||||
#define Py_DICTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Dictionary object type -- mapping from hashable object to object */
|
||||
|
||||
/* The distribution includes a separate file, Objects/dictnotes.txt,
|
||||
describing explorations into dictionary design and optimization.
|
||||
It covers typical dictionary use patterns, the parameters for
|
||||
tuning dictionaries, and several ideas for possible optimizations.
|
||||
*/
|
||||
|
||||
/*
|
||||
There are three kinds of slots in the table:
|
||||
|
||||
1. Unused. me_key == me_value == NULL
|
||||
Does not hold an active (key, value) pair now and never did. Unused can
|
||||
transition to Active upon key insertion. This is the only case in which
|
||||
me_key is NULL, and is each slot's initial state.
|
||||
|
||||
2. Active. me_key != NULL and me_key != dummy and me_value != NULL
|
||||
Holds an active (key, value) pair. Active can transition to Dummy upon
|
||||
key deletion. This is the only case in which me_value != NULL.
|
||||
|
||||
3. Dummy. me_key == dummy and me_value == NULL
|
||||
Previously held an active (key, value) pair, but that was deleted and an
|
||||
active pair has not yet overwritten the slot. Dummy can transition to
|
||||
Active upon key insertion. Dummy slots cannot be made Unused again
|
||||
(cannot have me_key set to NULL), else the probe sequence in case of
|
||||
collision would have no way to know they were once active.
|
||||
|
||||
Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to
|
||||
hold a search finger. The me_hash field of Unused or Dummy slots has no
|
||||
meaning otherwise.
|
||||
*/
|
||||
|
||||
/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are
|
||||
* allocated directly in the dict object (in the ma_smalltable member).
|
||||
* It must be a power of 2, and at least 4. 8 allows dicts with no more
|
||||
* than 5 active entries to live in ma_smalltable (and so avoid an
|
||||
* additional malloc); instrumentation suggested this suffices for the
|
||||
* majority of dicts (consisting mostly of usually-small instance dicts and
|
||||
* usually-small dicts created to pass keyword arguments).
|
||||
*/
|
||||
#define PyDict_MINSIZE 8
|
||||
|
||||
typedef struct {
|
||||
/* Cached hash code of me_key. Note that hash codes are C longs.
|
||||
* We have to use Py_ssize_t instead because dict_popitem() abuses
|
||||
* me_hash to hold a search finger.
|
||||
*/
|
||||
Py_ssize_t me_hash;
|
||||
PyObject *me_key;
|
||||
PyObject *me_value;
|
||||
} PyDictEntry;
|
||||
|
||||
/*
|
||||
To ensure the lookup algorithm terminates, there must be at least one Unused
|
||||
slot (NULL key) in the table.
|
||||
The value ma_fill is the number of non-NULL keys (sum of Active and Dummy);
|
||||
ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL
|
||||
values == the number of Active items).
|
||||
To avoid slowing down lookups on a near-full table, we resize the table when
|
||||
it's two-thirds full.
|
||||
*/
|
||||
typedef struct _dictobject PyDictObject;
|
||||
struct _dictobject {
|
||||
PyObject_HEAD
|
||||
Py_ssize_t ma_fill; /* # Active + # Dummy */
|
||||
Py_ssize_t ma_used; /* # Active */
|
||||
|
||||
/* The table contains ma_mask + 1 slots, and that's a power of 2.
|
||||
* We store the mask instead of the size because the mask is more
|
||||
* frequently needed.
|
||||
*/
|
||||
Py_ssize_t ma_mask;
|
||||
|
||||
/* ma_table points to ma_smalltable for small tables, else to
|
||||
* additional malloc'ed memory. ma_table is never NULL! This rule
|
||||
* saves repeated runtime null-tests in the workhorse getitem and
|
||||
* setitem calls.
|
||||
*/
|
||||
PyDictEntry *ma_table;
|
||||
PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash);
|
||||
PyDictEntry ma_smalltable[PyDict_MINSIZE];
|
||||
};
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDict_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
|
||||
|
||||
#define PyDict_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
|
||||
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
|
||||
#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type)
|
||||
#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type)
|
||||
#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type)
|
||||
/* This excludes Values, since they are not sets. */
|
||||
# define PyDictViewSet_Check(op) \
|
||||
(PyDictKeys_Check(op) || PyDictItems_Check(op))
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_New(void);
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
|
||||
PyAPI_FUNC(int) _PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
|
||||
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
|
||||
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
|
||||
|
||||
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
|
||||
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
|
||||
|
||||
/* PyDict_Merge updates/merges from a mapping object (an object that
|
||||
supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
|
||||
the last occurrence of a key wins, else the first. The Python
|
||||
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
|
||||
PyObject *other,
|
||||
int override);
|
||||
|
||||
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
|
||||
iterable objects of length 2. If override is true, the last occurrence
|
||||
of a key wins, else the first. The Python dict constructor dict(seq2)
|
||||
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
|
||||
PyObject *seq2,
|
||||
int override);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
|
||||
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_DICTOBJECT_H */
|
||||
15
python/include/dtoa.h
Normal file
15
python/include/dtoa.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef PY_NO_SHORT_FLOAT_REPR
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
|
||||
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
|
||||
int *decpt, int *sign, char **rve);
|
||||
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
17
python/include/enumobject.h
Normal file
17
python/include/enumobject.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef Py_ENUMOBJECT_H
|
||||
#define Py_ENUMOBJECT_H
|
||||
|
||||
/* Enumerate Object */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyEnum_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyReversed_Type;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_ENUMOBJECT_H */
|
||||
36
python/include/errcode.h
Normal file
36
python/include/errcode.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef Py_ERRCODE_H
|
||||
#define Py_ERRCODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Error codes passed around between file input, tokenizer, parser and
|
||||
interpreter. This is necessary so we can turn them into Python
|
||||
exceptions at a higher level. Note that some errors have a
|
||||
slightly different meaning when passed from the tokenizer to the
|
||||
parser than when passed from the parser to the interpreter; e.g.
|
||||
the parser only returns E_EOF when it hits EOF immediately, and it
|
||||
never returns E_OK. */
|
||||
|
||||
#define E_OK 10 /* No error */
|
||||
#define E_EOF 11 /* End Of File */
|
||||
#define E_INTR 12 /* Interrupted */
|
||||
#define E_TOKEN 13 /* Bad token */
|
||||
#define E_SYNTAX 14 /* Syntax error */
|
||||
#define E_NOMEM 15 /* Ran out of memory */
|
||||
#define E_DONE 16 /* Parsing complete */
|
||||
#define E_ERROR 17 /* Execution error */
|
||||
#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */
|
||||
#define E_OVERFLOW 19 /* Node had too many children */
|
||||
#define E_TOODEEP 20 /* Too many indentation levels */
|
||||
#define E_DEDENT 21 /* No matching outer block for dedent */
|
||||
#define E_DECODE 22 /* Error in decoding into Unicode */
|
||||
#define E_EOFS 23 /* EOF in triple-quoted string */
|
||||
#define E_EOLS 24 /* EOL in single-quoted string */
|
||||
#define E_LINECONT 25 /* Unexpected characters after a line continuation */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ERRCODE_H */
|
||||
25
python/include/eval.h
Normal file
25
python/include/eval.h
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/* Interface to execute compiled code */
|
||||
|
||||
#ifndef Py_EVAL_H
|
||||
#define Py_EVAL_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
PyObject **args, int argc,
|
||||
PyObject **kwds, int kwdc,
|
||||
PyObject **defs, int defc,
|
||||
PyObject *closure);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_EVAL_H */
|
||||
97
python/include/fileobject.h
Normal file
97
python/include/fileobject.h
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/* File object interface */
|
||||
|
||||
#ifndef Py_FILEOBJECT_H
|
||||
#define Py_FILEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
FILE *f_fp;
|
||||
PyObject *f_name;
|
||||
PyObject *f_mode;
|
||||
int (*f_close)(FILE *);
|
||||
int f_softspace; /* Flag used by 'print' command */
|
||||
int f_binary; /* Flag which indicates whether the file is
|
||||
open in binary (1) or text (0) mode */
|
||||
char* f_buf; /* Allocated readahead buffer */
|
||||
char* f_bufend; /* Points after last occupied position */
|
||||
char* f_bufptr; /* Current buffer position */
|
||||
char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */
|
||||
int f_univ_newline; /* Handle any newline convention */
|
||||
int f_newlinetypes; /* Types of newlines seen */
|
||||
int f_skipnextlf; /* Skip next \n */
|
||||
PyObject *f_encoding;
|
||||
PyObject *f_errors;
|
||||
PyObject *weakreflist; /* List of weak references */
|
||||
int unlocked_count; /* Num. currently running sections of code
|
||||
using f_fp with the GIL released. */
|
||||
int readable;
|
||||
int writable;
|
||||
} PyFileObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFile_Type;
|
||||
|
||||
#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type)
|
||||
#define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *);
|
||||
PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject *, const char *, char *errors);
|
||||
PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *,
|
||||
int (*)(FILE *));
|
||||
PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *);
|
||||
PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *);
|
||||
PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
|
||||
|
||||
/* The default encoding used by the platform file system APIs
|
||||
If non-NULL, this is different than the default encoding for strings
|
||||
*/
|
||||
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
|
||||
|
||||
/* Routines to replace fread() and fgets() which accept any of \r, \n
|
||||
or \r\n as line terminators.
|
||||
*/
|
||||
#define PY_STDIOTEXTMODE "b"
|
||||
char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
|
||||
size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *);
|
||||
|
||||
/* A routine to do sanity checking on the file mode string. returns
|
||||
non-zero on if an exception occurred
|
||||
*/
|
||||
int _PyFile_SanitizeMode(char *mode);
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1400
|
||||
/* A routine to check if a file descriptor is valid on Windows. Returns 0
|
||||
* and sets errno to EBADF if it isn't. This is to avoid Assertions
|
||||
* from various functions in the Windows CRT beginning with
|
||||
* Visual Studio 2005
|
||||
*/
|
||||
int _PyVerify_fd(int fd);
|
||||
#elif defined _MSC_VER && _MSC_VER >= 1200
|
||||
/* fdopen doesn't set errno EBADF and crashes for large fd on debug build */
|
||||
#define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0)
|
||||
#else
|
||||
#define _PyVerify_fd(A) (1) /* dummy */
|
||||
#endif
|
||||
|
||||
/* A routine to check if a file descriptor can be select()-ed. */
|
||||
#ifdef HAVE_SELECT
|
||||
#define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
|
||||
#else
|
||||
#define _PyIsSelectable_fd(FD) (1)
|
||||
#endif /* HAVE_SELECT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FILEOBJECT_H */
|
||||
140
python/include/floatobject.h
Normal file
140
python/include/floatobject.h
Normal file
@@ -0,0 +1,140 @@
|
||||
|
||||
/* Float object interface */
|
||||
|
||||
/*
|
||||
PyFloatObject represents a (double precision) floating point number.
|
||||
*/
|
||||
|
||||
#ifndef Py_FLOATOBJECT_H
|
||||
#define Py_FLOATOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
double ob_fval;
|
||||
} PyFloatObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
||||
|
||||
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
|
||||
|
||||
/* The str() precision PyFloat_STR_PRECISION is chosen so that in most cases,
|
||||
the rounding noise created by various operations is suppressed, while
|
||||
giving plenty of precision for practical use. */
|
||||
|
||||
#define PyFloat_STR_PRECISION 12
|
||||
|
||||
#ifdef Py_NAN
|
||||
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
|
||||
#endif
|
||||
|
||||
#define Py_RETURN_INF(sign) do \
|
||||
if (copysign(1., sign) == 1.) { \
|
||||
return PyFloat_FromDouble(Py_HUGE_VAL); \
|
||||
} else { \
|
||||
return PyFloat_FromDouble(-Py_HUGE_VAL); \
|
||||
} while(0)
|
||||
|
||||
PyAPI_FUNC(double) PyFloat_GetMax(void);
|
||||
PyAPI_FUNC(double) PyFloat_GetMin(void);
|
||||
PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void);
|
||||
|
||||
/* Return Python float from string PyObject. Second argument ignored on
|
||||
input, and, if non-NULL, NULL is stored into *junk (this tried to serve a
|
||||
purpose once but can't be made to work as intended). */
|
||||
PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk);
|
||||
|
||||
/* Return Python float from C double. */
|
||||
PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double);
|
||||
|
||||
/* Extract C double from Python float. The macro version trades safety for
|
||||
speed. */
|
||||
PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *);
|
||||
#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
|
||||
|
||||
/* Write repr(v) into the char buffer argument, followed by null byte. The
|
||||
buffer must be "big enough"; >= 100 is very safe.
|
||||
PyFloat_AsReprString(buf, x) strives to print enough digits so that
|
||||
PyFloat_FromString(buf) then reproduces x exactly. */
|
||||
PyAPI_FUNC(void) PyFloat_AsReprString(char*, PyFloatObject *v);
|
||||
|
||||
/* Write str(v) into the char buffer argument, followed by null byte. The
|
||||
buffer must be "big enough"; >= 100 is very safe. Note that it's
|
||||
unusual to be able to get back the float you started with from
|
||||
PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to
|
||||
preserve precision across conversions. */
|
||||
PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v);
|
||||
|
||||
/* _PyFloat_{Pack,Unpack}{4,8}
|
||||
*
|
||||
* The struct and pickle (at least) modules need an efficient platform-
|
||||
* independent way to store floating-point values as byte strings.
|
||||
* The Pack routines produce a string from a C double, and the Unpack
|
||||
* routines produce a C double from such a string. The suffix (4 or 8)
|
||||
* specifies the number of bytes in the string.
|
||||
*
|
||||
* On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats
|
||||
* these functions work by copying bits. On other platforms, the formats the
|
||||
* 4- byte format is identical to the IEEE-754 single precision format, and
|
||||
* the 8-byte format to the IEEE-754 double precision format, although the
|
||||
* packing of INFs and NaNs (if such things exist on the platform) isn't
|
||||
* handled correctly, and attempting to unpack a string containing an IEEE
|
||||
* INF or NaN will raise an exception.
|
||||
*
|
||||
* On non-IEEE platforms with more precision, or larger dynamic range, than
|
||||
* 754 supports, not all values can be packed; on non-IEEE platforms with less
|
||||
* precision, or smaller dynamic range, not all values can be unpacked. What
|
||||
* happens in such cases is partly accidental (alas).
|
||||
*/
|
||||
|
||||
/* The pack routines write 4 or 8 bytes, starting at p. le is a bool
|
||||
* argument, true if you want the string in little-endian format (exponent
|
||||
* last, at p+3 or p+7), false if you want big-endian format (exponent
|
||||
* first, at p).
|
||||
* Return value: 0 if all is OK, -1 if error (and an exception is
|
||||
* set, most likely OverflowError).
|
||||
* There are two problems on non-IEEE platforms:
|
||||
* 1): What this does is undefined if x is a NaN or infinity.
|
||||
* 2): -0.0 and +0.0 produce the same string.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le);
|
||||
PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le);
|
||||
|
||||
/* Used to get the important decimal digits of a double */
|
||||
PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum);
|
||||
PyAPI_FUNC(void) _PyFloat_DigitsInit(void);
|
||||
|
||||
/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool
|
||||
* argument, true if the string is in little-endian format (exponent
|
||||
* last, at p+3 or p+7), false if big-endian (exponent first, at p).
|
||||
* Return value: The unpacked double. On error, this is -1.0 and
|
||||
* PyErr_Occurred() is true (and an exception is set, most likely
|
||||
* OverflowError). Note that on a non-IEEE platform this will refuse
|
||||
* to unpack a string that represents a NaN or infinity.
|
||||
*/
|
||||
PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le);
|
||||
PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le);
|
||||
|
||||
/* free list api */
|
||||
PyAPI_FUNC(int) PyFloat_ClearFreeList(void);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
|
||||
char *format_spec,
|
||||
Py_ssize_t format_spec_len);
|
||||
|
||||
/* Round a C double x to the closest multiple of 10**-ndigits. Returns a
|
||||
Python float on success, or NULL (with an appropriate exception set) on
|
||||
failure. Used in builtin_round in bltinmodule.c. */
|
||||
PyAPI_FUNC(PyObject *) _Py_double_round(double x, int ndigits);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FLOATOBJECT_H */
|
||||
89
python/include/frameobject.h
Normal file
89
python/include/frameobject.h
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
/* Frame object interface */
|
||||
|
||||
#ifndef Py_FRAMEOBJECT_H
|
||||
#define Py_FRAMEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int b_type; /* what kind of block this is */
|
||||
int b_handler; /* where to jump to find handler */
|
||||
int b_level; /* value stack level to pop to */
|
||||
} PyTryBlock;
|
||||
|
||||
typedef struct _frame {
|
||||
PyObject_VAR_HEAD
|
||||
struct _frame *f_back; /* previous frame, or NULL */
|
||||
PyCodeObject *f_code; /* code segment */
|
||||
PyObject *f_builtins; /* builtin symbol table (PyDictObject) */
|
||||
PyObject *f_globals; /* global symbol table (PyDictObject) */
|
||||
PyObject *f_locals; /* local symbol table (any mapping) */
|
||||
PyObject **f_valuestack; /* points after the last local */
|
||||
/* Next free slot in f_valuestack. Frame creation sets to f_valuestack.
|
||||
Frame evaluation usually NULLs it, but a frame that yields sets it
|
||||
to the current stack top. */
|
||||
PyObject **f_stacktop;
|
||||
PyObject *f_trace; /* Trace function */
|
||||
|
||||
/* If an exception is raised in this frame, the next three are used to
|
||||
* record the exception info (if any) originally in the thread state. See
|
||||
* comments before set_exc_info() -- it's not obvious.
|
||||
* Invariant: if _type is NULL, then so are _value and _traceback.
|
||||
* Desired invariant: all three are NULL, or all three are non-NULL. That
|
||||
* one isn't currently true, but "should be".
|
||||
*/
|
||||
PyObject *f_exc_type, *f_exc_value, *f_exc_traceback;
|
||||
|
||||
PyThreadState *f_tstate;
|
||||
int f_lasti; /* Last instruction if called */
|
||||
/* Call PyFrame_GetLineNumber() instead of reading this field
|
||||
directly. As of 2.3 f_lineno is only valid when tracing is
|
||||
active (i.e. when f_trace is set). At other times we use
|
||||
PyCode_Addr2Line to calculate the line from the current
|
||||
bytecode index. */
|
||||
int f_lineno; /* Current line number */
|
||||
int f_iblock; /* index in f_blockstack */
|
||||
PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
|
||||
PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
|
||||
} PyFrameObject;
|
||||
|
||||
|
||||
/* Standard object interface */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFrame_Type;
|
||||
|
||||
#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
|
||||
#define PyFrame_IsRestricted(f) \
|
||||
((f)->f_builtins != (f)->f_tstate->interp->builtins)
|
||||
|
||||
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
|
||||
/* The rest of the interface is specific for frame objects */
|
||||
|
||||
/* Block management functions */
|
||||
|
||||
PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);
|
||||
PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *);
|
||||
|
||||
/* Extend the value stack */
|
||||
|
||||
PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int);
|
||||
|
||||
/* Conversions between "fast locals" and locals in dictionary */
|
||||
|
||||
PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int);
|
||||
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyFrame_ClearFreeList(void);
|
||||
|
||||
/* Return the line of code the frame is currently executing. */
|
||||
PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FRAMEOBJECT_H */
|
||||
76
python/include/funcobject.h
Normal file
76
python/include/funcobject.h
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
/* Function object interface */
|
||||
|
||||
#ifndef Py_FUNCOBJECT_H
|
||||
#define Py_FUNCOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Function objects and code objects should not be confused with each other:
|
||||
*
|
||||
* Function objects are created by the execution of the 'def' statement.
|
||||
* They reference a code object in their func_code attribute, which is a
|
||||
* purely syntactic object, i.e. nothing more than a compiled version of some
|
||||
* source code lines. There is one code object per source code "fragment",
|
||||
* but each code object can be referenced by zero or many function objects
|
||||
* depending only on how many times the 'def' statement in the source was
|
||||
* executed so far.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *func_code; /* A code object */
|
||||
PyObject *func_globals; /* A dictionary (other mappings won't do) */
|
||||
PyObject *func_defaults; /* NULL or a tuple */
|
||||
PyObject *func_closure; /* NULL or a tuple of cell objects */
|
||||
PyObject *func_doc; /* The __doc__ attribute, can be anything */
|
||||
PyObject *func_name; /* The __name__ attribute, a string object */
|
||||
PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */
|
||||
PyObject *func_weakreflist; /* List of weak references */
|
||||
PyObject *func_module; /* The __module__ attribute, can be anything */
|
||||
|
||||
/* Invariant:
|
||||
* func_closure contains the bindings for func_code->co_freevars, so
|
||||
* PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code)
|
||||
* (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0).
|
||||
*/
|
||||
} PyFunctionObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFunction_Type;
|
||||
|
||||
#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
#define PyFunction_GET_CODE(func) \
|
||||
(((PyFunctionObject *)func) -> func_code)
|
||||
#define PyFunction_GET_GLOBALS(func) \
|
||||
(((PyFunctionObject *)func) -> func_globals)
|
||||
#define PyFunction_GET_MODULE(func) \
|
||||
(((PyFunctionObject *)func) -> func_module)
|
||||
#define PyFunction_GET_DEFAULTS(func) \
|
||||
(((PyFunctionObject *)func) -> func_defaults)
|
||||
#define PyFunction_GET_CLOSURE(func) \
|
||||
(((PyFunctionObject *)func) -> func_closure)
|
||||
|
||||
/* The classmethod and staticmethod types lives here, too */
|
||||
PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FUNCOBJECT_H */
|
||||
40
python/include/genobject.h
Normal file
40
python/include/genobject.h
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
/* Generator object interface */
|
||||
|
||||
#ifndef Py_GENOBJECT_H
|
||||
#define Py_GENOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
/* The gi_ prefix is intended to remind of generator-iterator. */
|
||||
|
||||
/* Note: gi_frame can be NULL if the generator is "finished" */
|
||||
struct _frame *gi_frame;
|
||||
|
||||
/* True if generator is being executed. */
|
||||
int gi_running;
|
||||
|
||||
/* The code object backing the generator */
|
||||
PyObject *gi_code;
|
||||
|
||||
/* List of weak reference. */
|
||||
PyObject *gi_weakreflist;
|
||||
} PyGenObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyGen_Type;
|
||||
|
||||
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
|
||||
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_GENOBJECT_H */
|
||||
87
python/include/graminit.h
Normal file
87
python/include/graminit.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* Generated by Parser/pgen */
|
||||
|
||||
#define single_input 256
|
||||
#define file_input 257
|
||||
#define eval_input 258
|
||||
#define decorator 259
|
||||
#define decorators 260
|
||||
#define decorated 261
|
||||
#define funcdef 262
|
||||
#define parameters 263
|
||||
#define varargslist 264
|
||||
#define fpdef 265
|
||||
#define fplist 266
|
||||
#define stmt 267
|
||||
#define simple_stmt 268
|
||||
#define small_stmt 269
|
||||
#define expr_stmt 270
|
||||
#define augassign 271
|
||||
#define print_stmt 272
|
||||
#define del_stmt 273
|
||||
#define pass_stmt 274
|
||||
#define flow_stmt 275
|
||||
#define break_stmt 276
|
||||
#define continue_stmt 277
|
||||
#define return_stmt 278
|
||||
#define yield_stmt 279
|
||||
#define raise_stmt 280
|
||||
#define import_stmt 281
|
||||
#define import_name 282
|
||||
#define import_from 283
|
||||
#define import_as_name 284
|
||||
#define dotted_as_name 285
|
||||
#define import_as_names 286
|
||||
#define dotted_as_names 287
|
||||
#define dotted_name 288
|
||||
#define global_stmt 289
|
||||
#define exec_stmt 290
|
||||
#define assert_stmt 291
|
||||
#define compound_stmt 292
|
||||
#define if_stmt 293
|
||||
#define while_stmt 294
|
||||
#define for_stmt 295
|
||||
#define try_stmt 296
|
||||
#define with_stmt 297
|
||||
#define with_item 298
|
||||
#define except_clause 299
|
||||
#define suite 300
|
||||
#define testlist_safe 301
|
||||
#define old_test 302
|
||||
#define old_lambdef 303
|
||||
#define test 304
|
||||
#define or_test 305
|
||||
#define and_test 306
|
||||
#define not_test 307
|
||||
#define comparison 308
|
||||
#define comp_op 309
|
||||
#define expr 310
|
||||
#define xor_expr 311
|
||||
#define and_expr 312
|
||||
#define shift_expr 313
|
||||
#define arith_expr 314
|
||||
#define term 315
|
||||
#define factor 316
|
||||
#define power 317
|
||||
#define atom 318
|
||||
#define listmaker 319
|
||||
#define testlist_comp 320
|
||||
#define lambdef 321
|
||||
#define trailer 322
|
||||
#define subscriptlist 323
|
||||
#define subscript 324
|
||||
#define sliceop 325
|
||||
#define exprlist 326
|
||||
#define testlist 327
|
||||
#define dictorsetmaker 328
|
||||
#define classdef 329
|
||||
#define arglist 330
|
||||
#define argument 331
|
||||
#define list_iter 332
|
||||
#define list_for 333
|
||||
#define list_if 334
|
||||
#define comp_iter 335
|
||||
#define comp_for 336
|
||||
#define comp_if 337
|
||||
#define testlist1 338
|
||||
#define encoding_decl 339
|
||||
#define yield_expr 340
|
||||
93
python/include/grammar.h
Normal file
93
python/include/grammar.h
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
/* Grammar interface */
|
||||
|
||||
#ifndef Py_GRAMMAR_H
|
||||
#define Py_GRAMMAR_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "bitset.h" /* Sigh... */
|
||||
|
||||
/* A label of an arc */
|
||||
|
||||
typedef struct {
|
||||
int lb_type;
|
||||
char *lb_str;
|
||||
} label;
|
||||
|
||||
#define EMPTY 0 /* Label number 0 is by definition the empty label */
|
||||
|
||||
/* A list of labels */
|
||||
|
||||
typedef struct {
|
||||
int ll_nlabels;
|
||||
label *ll_label;
|
||||
} labellist;
|
||||
|
||||
/* An arc from one state to another */
|
||||
|
||||
typedef struct {
|
||||
short a_lbl; /* Label of this arc */
|
||||
short a_arrow; /* State where this arc goes to */
|
||||
} arc;
|
||||
|
||||
/* A state in a DFA */
|
||||
|
||||
typedef struct {
|
||||
int s_narcs;
|
||||
arc *s_arc; /* Array of arcs */
|
||||
|
||||
/* Optional accelerators */
|
||||
int s_lower; /* Lowest label index */
|
||||
int s_upper; /* Highest label index */
|
||||
int *s_accel; /* Accelerator */
|
||||
int s_accept; /* Nonzero for accepting state */
|
||||
} state;
|
||||
|
||||
/* A DFA */
|
||||
|
||||
typedef struct {
|
||||
int d_type; /* Non-terminal this represents */
|
||||
char *d_name; /* For printing */
|
||||
int d_initial; /* Initial state */
|
||||
int d_nstates;
|
||||
state *d_state; /* Array of states */
|
||||
bitset d_first;
|
||||
} dfa;
|
||||
|
||||
/* A grammar */
|
||||
|
||||
typedef struct {
|
||||
int g_ndfas;
|
||||
dfa *g_dfa; /* Array of DFAs */
|
||||
labellist g_ll;
|
||||
int g_start; /* Start symbol of the grammar */
|
||||
int g_accel; /* Set if accelerators present */
|
||||
} grammar;
|
||||
|
||||
/* FUNCTIONS */
|
||||
|
||||
grammar *newgrammar(int start);
|
||||
dfa *adddfa(grammar *g, int type, char *name);
|
||||
int addstate(dfa *d);
|
||||
void addarc(dfa *d, int from, int to, int lbl);
|
||||
dfa *PyGrammar_FindDFA(grammar *g, int type);
|
||||
|
||||
int addlabel(labellist *ll, int type, char *str);
|
||||
int findlabel(labellist *ll, int type, char *str);
|
||||
char *PyGrammar_LabelRepr(label *lb);
|
||||
void translatelabels(grammar *g);
|
||||
|
||||
void addfirstsets(grammar *g);
|
||||
|
||||
void PyGrammar_AddAccelerators(grammar *g);
|
||||
void PyGrammar_RemoveAccelerators(grammar *);
|
||||
|
||||
void printgrammar(grammar *g, FILE *fp);
|
||||
void printnonterminals(grammar *g, FILE *fp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_GRAMMAR_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user