pgraph: Add file_version property to BamFile (like BamReader/Writer)

This commit is contained in:
rdb 2023-05-05 10:52:46 +02:00
parent 749e297a02
commit 45fbfab094
4 changed files with 70 additions and 0 deletions

View File

@ -74,7 +74,11 @@ PUBLISHED:
BamReader *get_reader();
BamWriter *get_writer();
public:
EXTENSION(PyObject *get_file_version() const);
PUBLISHED:
MAKE_PROPERTY(file_version, get_file_version);
MAKE_PROPERTY(file_endian, get_file_endian);
MAKE_PROPERTY(file_stdfloat_double, get_file_stdfloat_double);

View File

@ -0,0 +1,28 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file bamFile_ext.cxx
* @author rdb
* @date 2023-05-03
*/
#include "bamFile_ext.h"
#include "bamWriter_ext.h"
#ifdef HAVE_PYTHON
/**
* Returns the version number of the Bam file currently being written.
*/
PyObject *Extension<BamFile>::
get_file_version() const {
return Py_BuildValue("(ii)", _this->get_file_major_ver(),
_this->get_file_minor_ver());
}
#endif

View File

@ -0,0 +1,37 @@
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file bamFile_ext.h
* @author rdb
* @date 2023-05-03
*/
#ifndef BAMFILE_EXT_H
#define BAMFILE_EXT_H
#include "dtoolbase.h"
#ifdef HAVE_PYTHON
#include "extension.h"
#include "bamFile.h"
#include "py_panda.h"
/**
* This class defines the extension methods for BamFile, which are called
* instead of any C++ methods with the same prototype.
*/
template<>
class Extension<BamFile> : public ExtensionBase<BamFile> {
public:
PyObject *get_file_version() const;
};
#endif // HAVE_PYTHON
#endif // BAMFILE_EXT_H

View File

@ -1,3 +1,4 @@
#include "bamFile_ext.cxx"
#include "loaderFileTypeRegistry_ext.cxx"
#include "nodePath_ext.cxx"
#include "nodePathCollection_ext.cxx"