#include <loc/as.h>
#include <loc/stringpool.h>
+#include "locationmodule.h"
#include "as.h"
-static PyObject* AS_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
- // Create libloc context
- struct loc_ctx* ctx;
- int r = loc_new(&ctx);
- if (r)
- return NULL;
+PyObject* new_as(PyTypeObject* type, struct loc_as* as) {
+ ASObject* self = (ASObject*)type->tp_alloc(type, 0);
+ if (self) {
+ self->as = loc_as_ref(as);
+ }
+ return (PyObject*)self;
+}
+
+static PyObject* AS_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
// Create stringpool
struct loc_stringpool* pool;
- r = loc_stringpool_new(ctx, &pool);
- if (r) {
- loc_unref(ctx);
+ int r = loc_stringpool_new(loc_ctx, &pool);
+ if (r)
return NULL;
- }
ASObject* self = (ASObject*)type->tp_alloc(type, 0);
if (self) {
- self->ctx = ctx;
+ self->ctx = loc_ref(loc_ctx);
self->pool = pool;
}