magic 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. magic cases might need to be treated specially and testcases are quite hard to produce.
  2. sv_magic()
  3. ----------
  4. av.c
  5. av_store()
  6. Storing a non-undef element into an SMAGICAL array, av,
  7. assigns the equivalent lowercase form of magic (of the first
  8. MAGIC in the chain) to the value (with obj = av, name = 0 and
  9. namlen = array index).
  10. gv.c
  11. gv_init()
  12. Initialising gv assigns '*' magic to it with obj = gv, name =
  13. GvNAME and namlen = GvNAMELEN.
  14. gv_fetchpv()
  15. @ISA gets 'I' magic with obj = gv, zero name and namlen.
  16. %OVERLOAD gets 'A' magic with obj = gv, zero name and namlen.
  17. $1 to $9, $&, $`, $', $+ get '\0' magic with obj = gv,
  18. name = GvNAME and namlen = len ( = 1 presumably).
  19. Gv_AMupdate()
  20. Stashes for overload magic seem to get 'c' magic with obj = 0,
  21. name = &amt and namlen = sizeof(amt).
  22. hv_magic(hv, gv, how)
  23. Gives magic how to hv with obj = gv and zero name and namlen.
  24. mg.c
  25. mg_copy(sv, nsv, key, klen)
  26. Traverses the magic chain of sv. Upper case forms of magic
  27. (only) are copied across to nsv, preserving obj but using
  28. name = key and namlen = klen.
  29. magic_setpos()
  30. LvTARG of a PVLV gets 'g' magic with obj = name = 0 and namlen = pos.
  31. op.c
  32. mod()
  33. PVLV operators give magic to their targs with
  34. obj = name = namlen = 0. OP_POS gives '.', OP_VEC gives 'v'
  35. and OP_SUBSTR gives 'x'.
  36. perl.c
  37. magicname(sym, name, namlen)
  38. Fetches/creates a GV with name sym and gives it '\0' magic
  39. with obj = gv, name and namlen as passed.
  40. init_postdump_symbols()
  41. Elements of the environment get given SVs with 'e' magic.
  42. obj = sv and name and namlen point to the actual string
  43. within env.
  44. pp.c
  45. pp_av2arylen()
  46. $#foo gives '#' magic to the new SV with obj = av and
  47. name = namlen = 0.
  48. pp_study()
  49. SV gets 'g' magic with obj = name = namlen = 0.
  50. pp_substr()
  51. PVLV gets 'x' magic with obj = name = namlen = 0.
  52. pp_vec()
  53. PVLV gets 'x' magic with obj = name = namlen = 0.
  54. pp_hot.c
  55. pp_match()
  56. m//g gets 'g' magic with obj = name = namlen = 0.
  57. pp_sys.c
  58. pp_tie()
  59. sv gets magic with obj = sv and name = namlen = 0.
  60. If an HV or an AV, it gets 'P' magic, otherwise 'q' magic.
  61. pp_dbmopen()
  62. 'P' magic for the HV just as with pp_tie().
  63. pp_sysread()
  64. If tainting, the buffer SV gets 't' magic with
  65. obj = name = namlen = 0.
  66. sv.c
  67. ref loops:
  68. For certain magics the sv == obj - a "magic reference loop":
  69. arylen, symtab, tiedscalar, .... There the obj refcount is
  70. not incremented.
  71. sv_setsv()
  72. Doing sv_setsv(dstr, gv) gives '*' magic to dstr with
  73. obj = dstr, name = GvNAME, namlen = GvNAMELEN.
  74. sv_setsv_flags()
  75. Set vstring on SvVSTRING_mg (RMAGIC)
  76. sv_rvweaken()
  77. tiedscalar weakens the RV obj to the PVIO. Sets a backref magic
  78. to the referred SV.
  79. util.c
  80. fbm_compile()
  81. The PVBM gets 'B' magic with obj = name = namlen = 0 and SvVALID
  82. is set to indicate that the Boyer-Moore table is valid.
  83. magic_setbm() just clears the SvVALID flag.
  84. hv_magic()
  85. ----------
  86. gv.c
  87. gv_fetchfile()
  88. With perldb, the HV of a gvfile gv gets 'L' magic with obj = gv.
  89. gv_fetchpv()
  90. %SIG gets 'S' magic with obj = siggv.
  91. init_postdump_symbols()
  92. %ENV gets 'E' magic with obj = envgv.