Skip to content

Commit

Permalink
Fix Imf/Iex/IlmThread namespaces in python bindings and website code (#…
Browse files Browse the repository at this point in the history
…1568)

* Fix Imf/Iex/IlmThread namespaces in python bindings and website code

Use OPENEXR_NAMESPACE, IEX_NAMESPACE, ILMTHREAD_NAMESPACE instead of
Imf, Iex, IlmThread, to support custom settings.

Signed-off-by: Cary Phillips <[email protected]>

* Use Iex:: namespace in example code instead of IEX_NAMESPACE

Requires this in all.cpp:

  namespace Iex = IEX_NAMESPACE;

Signed-off-by: Cary Phillips <[email protected]>

* use #define Iex

Signed-off-by: Cary Phillips <[email protected]>

* remove explicit Iex namespace

Signed-off-by: Cary Phillips <[email protected]>

---------

Signed-off-by: Cary Phillips <[email protected]>
  • Loading branch information
cary-ilm authored Sep 23, 2023
1 parent dc50388 commit 7c5c312
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/test/OpenEXRCoreTest/base_units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <iostream>

#include <ImfSystemSpecific.h>
#include <ImfNamespace.h>
#include "../../lib/OpenEXRCore/internal_cpuid.h"
#include "../../lib/OpenEXRCore/internal_coding.h"

Expand Down Expand Up @@ -364,7 +365,7 @@ testBaseDebug (const std::string& tempdir)
void testCPUIdent (const std::string& tempdir)
{
int hf16c, havx, hsse2;
Imf::CpuId id;
OPENEXR_IMF_NAMESPACE::CpuId id;
check_for_x86_simd (&hf16c, &havx, &hsse2);

if (hf16c != (int)id.f16c)
Expand Down
2 changes: 1 addition & 1 deletion src/test/OpenEXRTest/testCpuId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ testCpuId (const string&)
std::cout << "IMF_HAVE_AVX: " << false << "\n";
#endif

Imf::CpuId cpuId;
OPENEXR_IMF_NAMESPACE::CpuId cpuId;
std::cout << "cpuId.sse2: " << cpuId.sse2 << "\n";
std::cout << "cpuId.sse3: " << cpuId.sse3 << "\n";
std::cout << "cpuId.ssse3: " << cpuId.ssse3 << "\n";
Expand Down
16 changes: 8 additions & 8 deletions src/wrappers/python/OpenEXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ typedef int Py_ssize_t;
#endif

using namespace std;
using namespace Imf;
using namespace Imath;
using namespace OPENEXR_IMF_NAMESPACE;
using namespace IMATH_NAMESPACE;

static PyObject *OpenEXR_error = NULL;
static PyObject *pModuleImath;
Expand Down Expand Up @@ -155,7 +155,7 @@ C_IStream::read (char c[], int n)
memcpy(c, PyString_AsString(data), PyString_Size(data));
Py_DECREF(data);
} else {
throw Iex::InputExc("file read failed");
throw IEX_NAMESPACE::InputExc("file read failed");
}
return 0;
}
Expand All @@ -177,7 +177,7 @@ C_IStream::tellg ()
Py_DECREF(rv);
return (Int64)t;
} else {
throw Iex::InputExc("tell failed");
throw IEX_NAMESPACE::InputExc("tell failed");
}
}

Expand All @@ -188,7 +188,7 @@ C_IStream::seekg (Int64 pos)
if (data != NULL) {
Py_DECREF(data);
} else {
throw Iex::InputExc("seek failed");
throw IEX_NAMESPACE::InputExc("seek failed");
}
}

Expand Down Expand Up @@ -220,7 +220,7 @@ C_OStream::write (const char*c, int n)
if (data != NULL) {
Py_DECREF(data);
} else {
throw Iex::InputExc("file write failed");
throw IEX_NAMESPACE::InputExc("file write failed");
}
}

Expand All @@ -241,7 +241,7 @@ C_OStream::tellp ()
Py_DECREF(rv);
return (Int64)t;
} else {
throw Iex::InputExc("tell failed");
throw IEX_NAMESPACE::InputExc("tell failed");
}
}

Expand All @@ -252,7 +252,7 @@ C_OStream::seekp (Int64 pos)
if (data != NULL) {
Py_DECREF(data);
} else {
throw Iex::InputExc("seek failed");
throw IEX_NAMESPACE::InputExc("seek failed");
}
}

Expand Down
4 changes: 2 additions & 2 deletions website/src/C_IStream_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ C_IStream::read (char c[], int n)
// determine what happened.

if (ferror (_file))
Iex::throwErrnoExc();
throwErrnoExc();
else
throw Iex::InputExc ("Unexpected end of file.");
throw InputExc ("Unexpected end of file.");
}

return !feof (_file);
Expand Down
4 changes: 2 additions & 2 deletions website/src/MemoryMappedIStream_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ bool
MemoryMappedIStream::read (char c[], int n)
{
if (_readPosition >= _fileLength)
throw Iex::InputExc ("Unexpected end of file.");
throw InputExc ("Unexpected end of file.");

if (_readPosition + n > _fileLength)
throw Iex::InputExc ("Reading past end of file.");
throw InputExc ("Reading past end of file.");

memcpy (c, _buffer + _readPosition, n);

Expand Down
4 changes: 2 additions & 2 deletions website/src/MemoryMappedIStream_readMemoryMapped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ char *
MemoryMappedIStream::readMemoryMapped (int n)
{
if (_readPosition >= _fileLength)
throw Iex::InputExc ("Unexpected end of file.");
throw InputExc ("Unexpected end of file.");

if (_readPosition + n > _fileLength)
throw Iex::InputExc ("Reading past end of file.");
throw InputExc ("Reading past end of file.");

char *data = _buffer + _readPosition;

Expand Down
5 changes: 3 additions & 2 deletions website/src/all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
#include <unistd.h>
#endif

using namespace Imath;
using namespace Imf;
using namespace IMATH_NAMESPACE;
using namespace OPENEXR_IMF_NAMESPACE;
using namespace IEX_NAMESPACE;

using std::max;

Expand Down

0 comments on commit 7c5c312

Please sign in to comment.