Skip to content

Commit

Permalink
Updating latest changes from Main.
Browse files Browse the repository at this point in the history
  • Loading branch information
p4paul committed Jan 26, 2021
1 parent 3a24392 commit 5dadfc8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ include Version
include p4test.py
include job_trigger.py
include tools/*.py

global-exclude *.pyc
4 changes: 2 additions & 2 deletions P4API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: //depot/main/p4-python/P4API.cpp#62 $
* $Id: //depot/main/p4-python/P4API.cpp#63 $
*
* Build instructions:
* Use Distutils - see accompanying setup.py
Expand Down Expand Up @@ -237,7 +237,7 @@ static PyObject * P4Adapter_run(P4Adapter * self, PyObject * args)
// the other hack is that the API expects (char * const *), but this cannot be stored
// a std::vector<>, because it cannot exchange pointers

return self->clientAPI->Run(GetPythonString(cmd), argv.size(),
return self->clientAPI->Run(GetPythonString(cmd), (int)argv.size(),
(argv.size() > 0) ? (char * const *) &argv[0] : NULL );
}

Expand Down
51 changes: 31 additions & 20 deletions P4Result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$Id: //depot/main/p4-python/P4Result.cpp#19 $
$Id: //depot/main/p4-python/P4Result.cpp#21 $
*******************************************************************************/

#include <Python.h>
Expand Down Expand Up @@ -66,20 +66,25 @@ P4Result::~P4Result()
{
// reduce references to Python objects to avoid memory leaks

if (output)
if (output) {
Py_DECREF(output);

if (warnings)
}

if (warnings) {
Py_DECREF(warnings);

if (errors)
}

if (errors) {
Py_DECREF(errors);
}

if (messages)
if (messages) {
Py_DECREF(messages);
}

if (track)
Py_DECREF(track);
if (track) {
Py_DECREF(track);
}
}

PyObject * P4Result::GetOutput()
Expand All @@ -92,24 +97,29 @@ PyObject * P4Result::GetOutput()
void
P4Result::Reset()
{
if (output)
if (output) {
Py_DECREF(output);
}
output = PyList_New(0);

if (warnings)
if (warnings) {
Py_DECREF(warnings);
}
warnings = PyList_New(0);

if (errors)
if (errors) {
Py_DECREF(errors);
}
errors = PyList_New(0);

if (messages)
if (messages) {
Py_DECREF(messages);
}
messages = PyList_New(0);

if (track)
Py_DECREF(track);
if (track) {
Py_DECREF(track);
}
track = PyList_New(0);

if (output == NULL
Expand Down Expand Up @@ -154,8 +164,9 @@ int P4Result::AddTrack( PyObject * t )

void P4Result::ClearTrack()
{
if (track)
Py_DECREF(track);
if (track) {
Py_DECREF(track);
}
track = PyList_New(0);
}

Expand Down Expand Up @@ -221,13 +232,13 @@ P4Result::AddError( Error *e )
int
P4Result::ErrorCount()
{
return PyList_Size( errors );
return (int)PyList_Size( errors );
}

int
P4Result::WarningCount()
{
return PyList_Size( warnings );
return (int)PyList_Size( warnings );
}

void
Expand All @@ -246,7 +257,7 @@ P4Result::FmtWarnings( StrBuf &buf )
int
P4Result::Length( PyObject * list )
{
return PyList_Size( list );
return (int)PyList_Size( list );
}

void
Expand Down
4 changes: 2 additions & 2 deletions PythonClientAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$Id: //depot/main/p4-python/PythonClientAPI.cpp#77 $
$Id: //depot/main/p4-python/PythonClientAPI.cpp#78 $
*******************************************************************************/

#include <Python.h>
Expand Down Expand Up @@ -619,7 +619,7 @@ PyObject * PythonClientAPI::Convert(const char * charset, PyObject * content)
const char * contentAsUTF8 = PyBytes_AS_STRING(bytes);

int retlen = 0;
const char * converted = cvt->FastCvt(contentAsUTF8, strlen(contentAsUTF8), &retlen);
const char * converted = cvt->FastCvt(contentAsUTF8, (int)strlen(contentAsUTF8), &retlen);
Py_DECREF( bytes ); // we do not need this object anymore

if (converted == NULL) {
Expand Down
12 changes: 6 additions & 6 deletions SpecMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$Id: //depot/main/p4-python/SpecMgr.cpp#49 $
$Id: //depot/main/p4-python/SpecMgr.cpp#51 $
*******************************************************************************/

/*******************************************************************************
Expand Down Expand Up @@ -570,10 +570,10 @@ void SpecMgr::SplitKey( const StrPtr *key, StrBuf &base, StrBuf &index ) {
base = *key;
index = "";
for( size_t i = key->Length(); i; i-- ) {
char prev = (*key)[i - 1];
char prev = (*key)[(p4size_t)i - 1];
if( !isdigit(prev) && prev != ',' ) {
base.Set(key->Text(), i);
index.Set(key->Text() + i);
base.Set(key->Text(), (p4size_t)i);
index.Set(key->Text() + (p4size_t)i);
break;
}
}
Expand Down Expand Up @@ -659,7 +659,7 @@ void SpecMgr::InsertItem( PyObject * dict, const StrPtr *var, const StrPtr *val

for( const char *c = 0; (c = index.Contains(comma)); ) {
StrBuf level;
level.Set(index.Text(), c - index.Text());
level.Set(index.Text(), (int)(c - index.Text()));
index.Set(c + 1);

// Found another level so we need to get/create a nested array
Expand Down Expand Up @@ -703,7 +703,7 @@ void SpecMgr::InsertItem( PyObject * dict, const StrPtr *var, const StrPtr *val
}

buf = "... ";
buf << PyList_Size(list) << "] = " << val->Text();
buf << (int)PyList_Size(list) << "] = " << val->Text();

debug->debug ( P4PYDBG_DATA, buf.Text() );

Expand Down

0 comments on commit 5dadfc8

Please sign in to comment.