Changeset 103
- Timestamp:
- 03/05/07 17:30:51 (5 years ago)
- Files:
-
- trunk/examples/testdll/testdll.d (modified) (1 diff)
- trunk/infrastructure/pyd/class_wrap.d (modified) (10 diffs)
- trunk/infrastructure/pyd/struct_wrap.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/testdll/testdll.d
r100 r103 121 121 Foo, 122 122 Init!(void delegate(int), void delegate(int, int)), 123 Property!(Foo.i ),124 Def!(Foo.foo )125 ) ;123 Property!(Foo.i, "A sample property of Foo."), 124 Def!(Foo.foo, "A sample method of Foo.") 125 ) ("A sample class."); 126 126 127 127 wrap_struct!( 128 128 S, 129 Def!(S.write_s ),130 Member!("i" ),131 Member!("s" )132 ) ;129 Def!(S.write_s, "A struct member function."), 130 Member!("i", "One sample data member of S."), 131 Member!("s", "Another sample data member of S.") 132 ) ("A sample struct."); 133 133 } 134 134 trunk/infrastructure/pyd/class_wrap.d
r101 r103 274 274 if more than one function has the same name as this one. 275 275 */ 276 template Def(alias fn, char[] name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS=minArgs!(fn)) { 277 alias Def!(fn, symbolnameof!(fn), name, fn_t, MIN_ARGS) Def; 278 } 279 struct Def(alias fn, char[] _realname, char[] name, fn_t, uint MIN_ARGS) { 276 //template Def(alias fn, char[] name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS=minArgs!(fn), char[] docstring="") { 277 // alias Def!(fn, symbolnameof!(fn), name, fn_t, MIN_ARGS, docstring) Def; 278 //} 279 template Def(alias fn, char[] docstring="") { 280 alias Def!(fn, symbolnameof!(fn), symbolnameof!(fn), typeof(&fn), minArgs!(fn), docstring) Def; 281 } 282 template Def(alias fn, char[] name, char[] docstring) { 283 alias Def!(fn, symbolnameof!(fn), name, typeof(&fn), minArgs!(fn), docstring) Def; 284 } 285 template Def(alias fn, char[] name, fn_t, char[] docstring) { 286 alias Def!(fn, symbolnameof!(fn), name, fn_t, minArgs!(fn), docstring) Def; 287 } 288 template Def(alias fn, fn_t, char[] docstring="") { 289 alias Def!(fn, symbolnameof!(fn), symbolnameof!(fn), fn_t, minArgs!(fn), docstring) Def; 290 } 291 template Def(alias fn, char[] name, fn_t, uint MIN_ARGS=minArgs!(fn), char[] docstring="") { 292 alias Def!(fn, symbolnameof!(fn), name, fn_t, MIN_ARGS, docstring) Def; 293 } 294 struct Def(alias fn, char[] _realname, char[] name, fn_t, uint MIN_ARGS, char[] docstring) { 280 295 //static const type = ParamType.Def; 281 296 alias fn func; … … 292 307 list[length-1].ml_meth = &method_wrap!(T, fn, fn_t).func; 293 308 list[length-1].ml_flags = METH_VARARGS; 294 list[length-1].ml_doc = "";309 list[length-1].ml_doc = (docstring~\0).ptr; 295 310 list ~= empty; 296 311 // It's possible that appending the empty item invalidated the … … 310 325 Wraps a static member function of the class. Identical to pyd.def.def 311 326 */ 312 struct StaticDef(alias fn, char[] name = symbolnameof!(fn), fn_t=typeof(&fn), uint MIN_ARGS=minArgs!(fn)) { 327 template StaticDef(alias fn, char[] docstring="") { 328 alias StaticDef!(fn, symbolnameof!(fn), symbolnameof!(fn), typeof(&fn), minArgs!(fn), docstring) Def; 329 } 330 template StaticDef(alias fn, char[] name, char[] docstring) { 331 alias StaticDef!(fn, symbolnameof!(fn), name, typeof(&fn), minArgs!(fn), docstring) Def; 332 } 333 template StaticDef(alias fn, char[] name, fn_t, char[] docstring) { 334 alias StaticDef!(fn, symbolnameof!(fn), name, fn_t, minArgs!(fn), docstring) Def; 335 } 336 template StaticDef(alias fn, fn_t, char[] docstring="") { 337 alias StaticDef!(fn, symbolnameof!(fn), symbolnameof!(fn), fn_t, minArgs!(fn), docstring) Def; 338 } 339 template StaticDef(alias fn, char[] name, fn_t, uint MIN_ARGS=minArgs!(fn), char[] docstring="") { 340 alias StaticDef!(fn, symbolnameof!(fn), name, fn_t, MIN_ARGS, docstring) Def; 341 } 342 struct StaticDef(alias fn, char[] name, fn_t, uint MIN_ARGS, char[] docstring) { 313 343 //static const type = ParamType.StaticDef; 314 344 alias fn func; … … 323 353 list[length-1].ml_meth = &function_wrap!(fn, MIN_ARGS, fn_t).func; 324 354 list[length-1].ml_flags = METH_VARARGS | METH_STATIC; 325 list[length-1].ml_doc = "";355 list[length-1].ml_doc = (docstring~\0).ptr; 326 356 list ~= empty; 327 357 wrapped_class_type!(T).tp_methods = list; … … 340 370 RO = Whether this is a read-only property. 341 371 */ 342 template Property(alias fn, char[] name = symbolnameof!(fn), bool RO=false) { 343 alias Property!(fn, symbolnameof!(fn), name, RO) Property; 344 } 345 struct Property(alias fn, char[] _realname, char[] name, bool RO) { 372 //template Property(alias fn, char[] name = symbolnameof!(fn), bool RO=false, char[] docstring = "") { 373 // alias Property!(fn, symbolnameof!(fn), name, RO, docstring) Property; 374 //} 375 template Property(alias fn, char[] docstring="") { 376 alias Property!(fn, symbolnameof!(fn), symbolnameof!(fn), false, docstring) Property; 377 } 378 template Property(alias fn, char[] name, char[] docstring) { 379 alias Property!(fn, symbolnameof!(fn), name, false, docstring) Property; 380 } 381 template Property(alias fn, char[] name, bool RO, char[] docstring="") { 382 alias Property!(fn, symbolnameof!(fn), name, RO, docstring) Property; 383 } 384 template Property(alias fn, bool RO, char[] docstring="") { 385 alias Property!(fn, symbolnameof!(fn), symbolnameof!(fn), RO, docstring) Property; 386 } 387 struct Property(alias fn, char[] _realname, char[] name, bool RO, char[] docstring) { 346 388 alias property_parts!(fn).getter_type get_t; 347 389 alias property_parts!(fn).setter_type set_t; … … 359 401 &wrapped_set!(T, fn).func; 360 402 } 361 wrapped_prop_list!(T)[length-1].doc = "";403 wrapped_prop_list!(T)[length-1].doc = (docstring~\0).ptr; 362 404 wrapped_prop_list!(T)[length-1].closure = null; 363 405 wrapped_prop_list!(T) ~= empty; … … 453 495 iterator. 454 496 */ 455 struct AltIter(alias fn, char[] name = symbolnameof!(fn), iter_t = funcDelegInfoT!(typeof(&fn)).Meta.ArgType!(0)) {497 struct AltIter(alias fn, char[] name = symbolnameof!(fn), iter_t = ParameterTypeTuple!(fn)[0]) { 456 498 static void call(T, shim) () { 457 499 static PyMethodDef empty = { null, null, 0, null }; … … 461 503 list[length-1].ml_meth = cast(PyCFunction)&wrapped_iter!(T, fn, int function(iter_t)).iter; 462 504 list[length-1].ml_flags = METH_VARARGS; 463 list[length-1].ml_doc = (docstring ~ \0).ptr;505 list[length-1].ml_doc = "";//(docstring ~ \0).ptr; 464 506 list ~= empty; 465 507 // It's possible that appending the empty item invalidated the … … 481 523 alias make_wrapper!(_T, Params).wrapper shim_class; 482 524 alias _T T; 525 // } else static if (is(_T == interface)) { 526 // pragma(msg, "wrap_interface: " ~ name); 527 // alias make_wrapper!(_T, Params).wrapper shim_class; 528 // alias _T T; 483 529 } else { 484 530 pragma(msg, "wrap_struct: " ~ name); … … 588 634 wrapped_classes[T.classinfo] = &type; 589 635 wrapped_classes[shim_class.classinfo] = &type; 636 } 637 } 638 639 //////////////// 640 // DOCSTRINGS // 641 //////////////// 642 643 struct Docstring { 644 char[] name, doc; 645 } 646 647 void docstrings(T=void)(Docstring[] docs...) { 648 static if (is(T == void)) { 649 590 650 } 591 651 } trunk/infrastructure/pyd/struct_wrap.d
r101 r103 63 63 } 64 64 65 struct Member(char[] realname, char[] name=realname) { 65 template Member(char[] realname, char[] docstring="") { 66 alias Member!(realname, realname, docstring) Member; 67 } 68 struct Member(char[] realname, char[] name, char[] docstring) { 66 69 static void call(T, dummy) () { 67 70 pragma(msg, "struct.member: " ~ name); … … 71 74 list[length-1].get = &wrapped_member!(T, realname).get; 72 75 list[length-1].set = &wrapped_member!(T, realname).set; 73 list[length-1].doc = "";76 list[length-1].doc = (docstring~\0).ptr; 74 77 list[length-1].closure = null; 75 78 list ~= empty;
