commit 81f044b5c969970b6f050b7a4c2b1efae7c8634f
parent 4289150d3bd6aacb1919bf167a1805699ff1cf36
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 24 May 2005 11:18:12 +0000
bye
Diffstat:
8 files changed, 0 insertions(+), 182 deletions(-)
diff --git a/notes/Bag.h b/notes/Bag.h
@@ -1,13 +0,0 @@
-/*
- Bag.h
-
- Christian Seberino
- chris@pythonsoft.com
- November 5, 2004
-
- Defines the Bag structure.
-*/
-
-struct Bag {
- int data[3];
-};
diff --git a/notes/Makefile b/notes/Makefile
@@ -1,13 +0,0 @@
-# Makefile
-#
-# Christian Seberino
-# chris@pythonsoft.com
-# November 5, 2004
-#
-# Simple Makefile that builds the cbag shared object.
-
-all:
- gcc cbag.c -o cbag.so -I /usr/include/python2.2 -fpic -shared
-
-clean:
- rm -f *.so *.pyc
diff --git a/notes/bag.py b/notes/bag.py
@@ -1,11 +0,0 @@
-import cbag
-
-class Bag:
- def __init__(self):
- self.my_bag = cbag.init()
-
- def set(self, index, new_val):
- cbag.set(self.my_bag, index, new_val)
-
- def get(self, index):
- return cbag.get(self.my_bag, index)
diff --git a/notes/bag.pyc b/notes/bag.pyc
Binary files differ.
diff --git a/notes/cbag.c b/notes/cbag.c
@@ -1,105 +0,0 @@
-/*
- cbag.c
-
- Christian Seberino
- chris@pythonsoft.com
- November 5, 2004
-
- The cbag module.
-*/
-
-#include <Python.h>
-#include "Bag.h"
-
-/* Create a Bag object and returns a corresponding PyCObject reference. */
-
-static PyObject* init(PyObject *self, PyObject *args) {
- static struct Bag *my_bag;
-
- /* Create and set initial values. */
-
- my_bag = malloc(sizeof(struct Bag));
- my_bag->data[0] = 100;
- my_bag->data[0] = 100;
- my_bag->data[0] = 100;
-
- /* Returns a PyCObject reference corresponding to my_bag. */
-
- return PyCObject_FromVoidPtr((void*) my_bag, NULL);
-}
-
-/* Set an element of a Bag object array. */
-
-static PyObject* set(PyObject* self, PyObject* args) {
- int index, new_value;
- PyObject *py_my_bag;
- struct Bag *my_bag;
-
- /* Extract C variables from arguments. */
-
- PyArg_ParseTuple(args, "Oii", &py_my_bag, &index, &new_value);
-
- /* Extract my_bag from py_my_bag. */
-
- my_bag = (struct Bag*) PyCObject_AsVoidPtr(py_my_bag);
-
- /* Set desired element of Bag object array. */
-
- my_bag->data[index] = new_value;
-
- /* Increase reference count to the None object. */
-
- Py_INCREF(Py_None);
-
-
- /* Returns a new reference to the None object. */
-
- return Py_None;
-}
-
-/* Get an element of a Bag object array. */
-
-static PyObject* get(PyObject* self, PyObject* args) {
- int index;
- PyObject *py_my_bag;
- struct Bag *my_bag;
-
- /* Extract C variables from arguments. */
-
- PyArg_ParseTuple(args, "Oi", &py_my_bag, &index);
-
- /* Extract my_bag from py_my_bag. */
-
- my_bag = (struct Bag*) PyCObject_AsVoidPtr(py_my_bag);
-
- /* Return corresponding Python object to element with given index. */
-
- return Py_BuildValue("i", my_bag->data[index]);
-}
-
-/* Creating strings for Python documentation. */
-
-static char cbag_doc[] =
- "Bag functions.\n";
-
-static char init_doc[] =
- "Create a Bag and return a corresponding object to it.\n";
-
-static char set_doc[] =
- "Sets an element of Bag object data.\n";
-
-static char get_doc[] =
- "Get an element of Bag object data.\n";
-
-static PyMethodDef mapper[] = {
- {"init", (PyCFunction) init, METH_VARARGS, init_doc},
- {"set", (PyCFunction) set, METH_VARARGS, set_doc},
- {"get", (PyCFunction) get, METH_VARARGS, get_doc},
- {NULL}
-};
-
-/* Initialization function called when importing module. */
-
-void initcbag() {
- Py_InitModule3("cbag", mapper, cbag_doc);
-};
diff --git a/notes/cbag.so b/notes/cbag.so
Binary files differ.
diff --git a/notes/test b/notes/test
@@ -1,40 +0,0 @@
-#!/usr/bin/env python
-#
-# test
-#
-# Christian Seberino
-# chris@pythonsoft.com
-# November 5, 2004
-#
-# Tests code to demo saving state between C extensions.
-
-import bag
-
-print "Now I will create a Bag object..."
-
-my_bag = bag.Bag()
-
-print "Now I will set the 3 integers of the Bag object to 2, 33 and 4..."
-
-my_bag.set(0, 2)
-my_bag.set(1, 33)
-my_bag.set(2, 4)
-
-print "Now I will print the values of the 3 integers in the Bag object..."
-
-print my_bag.get(0), my_bag.get(1), my_bag.get(2)
-
-print "Now I will pass the object to a function and invoke that function..."
-
-def print_nuke_print_again(victim):
- """
- This function prints values of a Bag object, sets all values
- to zero and then prints values again.
- """
- print "BEFORE:", victim.get(0), victim.get(1), victim.get(2)
- victim.set(0, 0)
- victim.set(1, 0)
- victim.set(2, 0)
- print "AFTER: ", victim.get(0), victim.get(1), victim.get(2)
-
-print_nuke_print_again(my_bag)
diff --git a/notes/xpdf-3.00-64.17.src.rpm b/notes/xpdf-3.00-64.17.src.rpm
Binary files differ.