mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
bbbb8e96dd
Summary: Now uniondatapackstore can also hold python data stores. PythonDataStore wrapper simply passes function calls to underlying python objects and marshals the output. Test Plan: * Added test case * Tested on fbsource with treemanifest.usecunionstore=True Reviewers: durham, simonfar, ryanmce, #fbhgext Reviewed By: durham, simonfar, #fbhgext Differential Revision: https://phab.mercurial-scm.org/D631
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
// pythonkeyiterator.h - c++ implementation of python key iterator
|
|
//
|
|
// Copyright 2017 Facebook, Inc.
|
|
//
|
|
// This software may be used and distributed according to the terms of the
|
|
// GNU General Public License version 2 or any later version.
|
|
//
|
|
// no-check-code
|
|
|
|
#ifndef FBHGEXT_PYTHONKEYITERATOR_H
|
|
#define FBHGEXT_PYTHONKEYITERATOR_H
|
|
|
|
#include "cstore/pythonutil.h"
|
|
|
|
class PythonKeyIterator : public KeyIterator {
|
|
private:
|
|
PythonObj _input;
|
|
Key _current;
|
|
|
|
public:
|
|
PythonKeyIterator(PythonObj input) :
|
|
_input(input) {}
|
|
|
|
Key *next() {
|
|
PyObject *item;
|
|
while ((item = PyIter_Next((PyObject*)_input)) != NULL) {
|
|
PythonObj itemObj(item);
|
|
|
|
char *name;
|
|
Py_ssize_t namelen;
|
|
char *node;
|
|
Py_ssize_t nodelen;
|
|
if (!PyArg_ParseTuple(item, "s#s#", &name, &namelen, &node, &nodelen)) {
|
|
throw pyexception();
|
|
}
|
|
|
|
_current = Key(name, namelen, node, nodelen);
|
|
return &_current;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
};
|
|
|
|
#endif //FBHGEXT_PYTHONKEYITERATOR_H
|