-í
WÔj<c       sm     d  Z  8 : d k Z < g  d  Z F g  d  Z P g  d  Z Z d   Z k d   Z x d   Z d S(   sŇ  Utility functions for IDL compilers

escapifyString() -- return a string with non-printing characters escaped.
slashName()      -- format a scoped name with '/' separating components.
dotName()        -- format a scoped name with '.' separating components.
ccolonName()     -- format a scoped name with '::' separating components.
pruneScope()     -- remove common prefix from a scoped name.
relativeScope()  -- give a minimal name for one scope relative to another.Nc    s/   < A C t  |  |  } D t i | d  Sd S(   sÜ   slashName(list, [list]) -> string

Return a scoped name given as a list of strings as a single string
with the components separated by '/' characters. If a second list is
given, remove a common prefix using pruneScope().s   /N(   s
   pruneScopes
   scopedNames	   our_scopes   pscopes   strings   join(   s
   scopedNames	   our_scopes   pscope(    (    s   ./omniidl/idlutil.pys	   slashName< s   c    s/   F K M t  |  |  } N t i | d  Sd S(   sÚ   dotName(list, [list]) -> string

Return a scoped name given as a list of strings as a single string
with the components separated by '.' characters. If a second list is
given, remove a common prefix using pruneScope().s   .N(   s
   pruneScopes
   scopedNames	   our_scopes   pscopes   strings   join(   s
   scopedNames	   our_scopes   pscope(    (    s   ./omniidl/idlutil.pys   dotNameF s   c    s/   P U W t  |  |  } X t i | d  Sd S(   sŰ   ccolonName(list, [list]) -> string

Return a scoped name given as a list of strings as a single string
with the components separated by '::' strings. If a second list is
given, remove a common prefix using pruneScope().s   ::N(   s
   pruneScopes
   scopedNames	   our_scopes   pscopes   strings   join(   s
   scopedNames	   our_scopes   pscope(    (    s   ./omniidl/idlutil.pys
   ccolonNameP s   c    s   Z ` b |  } c d } d xZ d t |  d j o% | t |  j  o | d | | j o g | d =h | d } q Wi | Sd S(   sŘ   pruneScope(list A, list B) -> list

Given two lists of strings (scoped names), return a copy of list A
with any prefix it shares with B removed.

  e.g. pruneScope(['A', 'B', 'C', 'D'], ['A', 'B', 'D']) -> ['C', 'D']i    i   N(   s   target_scopes   tscopes   is   lens	   our_scope(   s   target_scopes	   our_scopes   is   tscope(    (    s   ./omniidl/idlutil.pys
   pruneScopeZ s   
	 >
c    s   k n p t  |   } q t i t i d } r xP t t |   Dr ]9 } s | | | j o t d t
 | |  | | <n qB Wu t i | d  Sd S(   sc   escapifyString(string) -> string

Return the given string with any non-printing characters escaped.s    _!$%^&*()-=+[]{};'#:@~,./<>?|`s   \%03os    N(   s   lists   strs   ls   strings   letterss   digitss   viss   ranges   lens   is   ords   join(   s   strs   viss   is   l(    (    s   ./omniidl/idlutil.pys   escapifyStringk s    	#c    s)   x    d k  } Ą | i |  |  Sd S(   sW  relativeScope(fromScope, destScope) -> list

Given two globally-scoped names, return a minimal scoped name list
which identifies the destination scope, without clashing with another
identifier. For example, given IDL:

  module M {
    typedef short A;
    typedef long  B;

    module N {
      typedef string B;
      interface I {
        void op(in ::M::A x, in ::M::B y);
      };
    };
  };

relativeScope(["M", "N", "I"], ["M", "A"]) -> ["A"]
relativeScope(["M", "N", "I"], ["M", "B"]) -> ["M", "B"]

If the only valid result is a globally-scoped name, the result list is
prefixed with None:

  module O {
    typedef short C;
  };
  module P {
    module O {
      interface J {
        void op(in ::O::C z);
      };
    };
  };

relativeScope(["P", "O", "J"], ["O", "C"]) -> [None, "O", "C"]

If either scoped name does not exist, returns None.N(   s   _omniidls   relativeScopedNames	   fromScopes	   destScope(   s	   fromScopes	   destScopes   _omniidl(    (    s   ./omniidl/idlutil.pys   relativeScopex s   &(   s   __doc__s   strings	   slashNames   dotNames
   ccolonNames
   pruneScopes   escapifyStrings   relativeScope(   s   escapifyStrings
   ccolonNames   strings
   pruneScopes   relativeScopes   dotNames	   slashName(    (    s   ./omniidl/idlutil.pys   ?8 s   


