]>
Commit | Line | Data |
---|---|---|
09ee8e72 RD |
1 | *** python.cxx.old Fri Jan 02 22:17:40 1998 |
2 | --- python.cxx Fri Aug 28 14:49:18 1998 | |
3 | *************** | |
4 | *** 1679,1684 **** | |
5 | --- 1679,1701 ---- | |
6 | } | |
7 | } | |
8 | } | |
9 | + } else if (strcmp(cmd, "addtomethod") == 0) { | |
10 | + // parse value, expected to be in the form "methodName:line" | |
11 | + char* txtptr = strchr(value, ':'); | |
12 | + if (txtptr) { | |
13 | + // add name and line to a list in current_class | |
14 | + *txtptr = 0; | |
15 | + txtptr++; | |
16 | + AddPragmaData* apData = new AddPragmaData(value, txtptr); | |
17 | + current_class->addPragmas.append(apData); | |
18 | + | |
19 | + } else { | |
20 | + fprintf(stderr,"%s : Line %d. Malformed addtomethod pragma. Should be \"methodName:text\"\n", | |
21 | + input_file, line_number); | |
22 | + } | |
23 | + } else if (strcmp(cmd, "addtoclass") == 0) { | |
24 | + AddPragmaData* apData = new AddPragmaData("__class__", value); | |
25 | + current_class->addPragmas.append(apData); | |
26 | } else { | |
27 | fprintf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file, line_number); | |
28 | } | |
29 | *** python.h.old Thu Jul 24 22:18:50 1997 | |
30 | --- python.h Fri Aug 28 14:46:08 1998 | |
31 | *************** | |
32 | *** 185,191 **** | |
33 | --- 185,203 ---- | |
34 | void cpp_class_decl(char *, char *,char *); | |
35 | void pragma(char *, char *, char *); | |
36 | void add_typedef(DataType *t, char *name); | |
37 | + | |
38 | + void emitAddPragmas(String& output, char* name, char* spacing); | |
39 | }; | |
40 | ||
41 | #define PYSHADOW_MEMBER 0x2 | |
42 | + | |
43 | + struct AddPragmaData { | |
44 | + String m_method; | |
45 | + String m_text; | |
46 | + | |
47 | + AddPragmaData(char* method, char* text) | |
48 | + : m_method(method), | |
49 | + m_text(text) | |
50 | + {} | |
51 | + }; | |
52 | ||
53 | *** pycpp.cxx.old Fri Jan 02 20:23:22 1998 | |
54 | --- pycpp.cxx Fri Aug 28 16:01:46 1998 | |
55 | *************** | |
56 | *** 276,281 **** | |
57 | --- 276,282 ---- | |
58 | } | |
59 | } | |
60 | // if ((t->type != T_VOID) || (t->is_pointer)) | |
61 | + emitAddPragmas(*pyclass, realname, tab8); | |
62 | *pyclass << tab8 << "return val\n"; | |
63 | ||
64 | // Change the usage string to reflect our shadow class | |
65 | *************** | |
66 | *** 394,399 **** | |
67 | --- 395,401 ---- | |
68 | } | |
69 | *construct << ")\n"; | |
70 | *construct << tab8 << "self.thisown = 1\n"; | |
71 | + emitAddPragmas(*construct, "__init__", tab8); | |
72 | have_constructor = 1; | |
73 | } else { | |
74 | ||
75 | *************** | |
76 | *** 494,502 **** | |
77 | *pyclass << tab4 << "def __del__(self):\n" | |
78 | << tab8 << "if self.thisown == 1 :\n" | |
79 | << tab8 << tab4 << module << "." << name_destroy(realname) << "(self.this)\n"; | |
80 | ! | |
81 | have_destructor = 1; | |
82 | - | |
83 | if (doc_entry) { | |
84 | doc_entry->usage = ""; | |
85 | doc_entry->usage << "del this"; | |
86 | --- 496,503 ---- | |
87 | *pyclass << tab4 << "def __del__(self):\n" | |
88 | << tab8 << "if self.thisown == 1 :\n" | |
89 | << tab8 << tab4 << module << "." << name_destroy(realname) << "(self.this)\n"; | |
90 | ! emitAddPragmas(*pyclass, "__del__", tab8); | |
91 | have_destructor = 1; | |
92 | if (doc_entry) { | |
93 | doc_entry->usage = ""; | |
94 | doc_entry->usage << "del this"; | |
95 | *************** | |
96 | *** 552,557 **** | |
97 | --- 553,560 ---- | |
98 | << tab8 << "return \"<C " << class_name <<" instance>\"\n"; | |
99 | ||
100 | classes << repr; | |
101 | + emitAddPragmas(classes, "__class__", tab4); | |
102 | + | |
103 | } | |
104 | ||
105 | // Now build the real class with a normal constructor | |
106 | *************** | |
107 | *** 747,752 **** | |
108 | --- 750,777 ---- | |
109 | } | |
110 | } | |
111 | ||
112 | + // -------------------------------------------------------------------------------- | |
113 | + // PYTHON::emitAddPragmas(String& output, char* name, char* spacing); | |
114 | + // | |
115 | + // Search the current_class->addPragmas vector for any text belonging to name. | |
116 | + // Append the text properly spcaed to the output string. | |
117 | + // | |
118 | + // -------------------------------------------------------------------------------- | |
119 | + | |
120 | + void PYTHON::emitAddPragmas(String& output, char* name, char* spacing) | |
121 | + { | |
122 | + AddPragmaData* apData; | |
123 | + size_t count; | |
124 | + int i; | |
125 | + | |
126 | + count = current_class->addPragmas.count(); | |
127 | + for (i=0; i<count; i++) { | |
128 | + apData = (AddPragmaData*)current_class->addPragmas[i]; | |
129 | + if (strcmp(apData->m_method, name) == 0) { | |
130 | + output << spacing << apData->m_text << "\n"; | |
131 | + } | |
132 | + } | |
133 | + } | |
134 | ||
135 | /********************************************************************************* | |
136 | * |