glue.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. Copyright (c) 2015-2018 Bruce A Henderson
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright notice, this
  7. list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  12. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  14. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  15. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  16. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  17. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  18. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  20. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. */
  22. #include "glue.h"
  23. extern "C" {
  24. BBLONG gfx_bxstream_TBxStreamWrapper__seek(BBObject *, BBLONG, int);
  25. int gfx_bxstream_TBxStreamWrapper__read(BBObject *, void *, int);
  26. int gfx_bxstream_TBxStreamWrapper__write(BBObject *, const void *, int);
  27. int gfx_bxstream_TBxStreamWrapper__close(BBObject *);
  28. MaxBxStream * bmx_bx_stream_new(BBObject * obj);
  29. void bmx_bx_stream_free(MaxBxStream * stream);
  30. }
  31. // --------------------------------------------------------
  32. MaxBxStream::MaxBxStream(BBObject * stream)
  33. : maxStream(stream) {
  34. BBRETAIN(stream);
  35. }
  36. MaxBxStream::~MaxBxStream() {
  37. BBRELEASE(maxStream);
  38. }
  39. int64_t MaxBxStream::seek(int64_t offset, bx::Whence::Enum whence) {
  40. return gfx_bxstream_TBxStreamWrapper__seek(maxStream, offset, whence);
  41. }
  42. int32_t MaxBxStream::write(const void* data, int32_t size, bx::Error * err) {
  43. return gfx_bxstream_TBxStreamWrapper__write(maxStream, data, size);
  44. }
  45. int32_t MaxBxStream::read(void* data, int32_t size, bx::Error* err) {
  46. return gfx_bxstream_TBxStreamWrapper__read(maxStream, data, size);
  47. }
  48. void MaxBxStream::close() {
  49. gfx_bxstream_TBxStreamWrapper__close(maxStream);
  50. }
  51. // --------------------------------------------------------
  52. MaxBxStream * bmx_bx_stream_new(BBObject * obj) {
  53. return new MaxBxStream(obj);
  54. }
  55. void bmx_bx_stream_free(MaxBxStream * stream) {
  56. delete stream;
  57. }