コード例 #1
0
    internal Procedure( Interp interp, NamespaceCmd.Namespace ns, string name, TclObject args, TclObject b, string sFileName, int sLineNumber )
    {
      this.ns = ns;
      srcFileName = sFileName;
      srcLineNumber = sLineNumber;

      // Break up the argument list into argument specifiers, then process
      // each argument specifier.

      int numArgs = TclList.getLength( interp, args );
      argList = new TclObject[numArgs][];
      for ( int i = 0; i < numArgs; i++ )
      {
        argList[i] = new TclObject[2];
      }

      for ( int i = 0; i < numArgs; i++ )
      {
        // Now divide the specifier up into name and default.

        TclObject argSpec = TclList.index( interp, args, i );
        int specLen = TclList.getLength( interp, argSpec );

        if ( specLen == 0 )
        {
          throw new TclException( interp, "procedure \"" + name + "\" has argument with no name" );
        }
        if ( specLen > 2 )
        {

          throw new TclException( interp, "too many fields in argument " + "specifier \"" + argSpec + "\"" );
        }

        argList[i][0] = TclList.index( interp, argSpec, 0 );
        argList[i][0].preserve();
        if ( specLen == 2 )
        {
          argList[i][1] = TclList.index( interp, argSpec, 1 );
          argList[i][1].preserve();
        }
        else
        {
          argList[i][1] = null;
        }
      }


      if ( numArgs > 0 && ( argList[numArgs - 1][0].ToString().Equals( "args" ) ) )
      {
        isVarArgs = true;
      }
      else
      {
        isVarArgs = false;
      }


      body = new CharPointer( b.ToString() );
      body_length = body.length();
    }
コード例 #2
0
ファイル: NamespaceCmd.cs プロジェクト: Belxjander/Asuna
		/*
		*----------------------------------------------------------------------
		*
		* SetNsNameFromAny -> setNsNameFromAny
		*
		*	Attempt to generate a nsName internal representation for a
		*	TclObject.
		*
		* Results:
		*	Returns if the value could be converted to a proper
		*	namespace reference. Otherwise, raises TclException.
		*
		* Side effects:
		*	If successful, the object is made a nsName object. Its internal rep
		*	is set to point to a ResolvedNsName, which contains a cached pointer
		*	to the Namespace. Reference counts are kept on both the
		*	ResolvedNsName and the Namespace, so we can keep track of their
		*	usage and free them when appropriate.
		*
		*----------------------------------------------------------------------
		*/
		
		private static void  setNsNameFromAny(Interp interp, TclObject tobj)
		{
			string name;
			Namespace ns;
			ResolvedNsName resName;
			
			// Java does not support passing an address so we pass
			// an array of size 1 and then assign arr[0] to the value
			Namespace[] nsArr = new Namespace[1];
			Namespace[] dummy1Arr = new Namespace[1];
			string[] dummy2Arr = new string[1];
			
			// Get the string representation.
			
			name = tobj.ToString();
			
			// Look for the namespace "name" in the current namespace. If there is
			// an error parsing the (possibly qualified) name, return an error.
			// If the namespace isn't found, we convert the object to an nsName
			// object with a null ResolvedNsName internal rep.
			
			getNamespaceForQualName(interp, name, null, TCL.VarFlag.FIND_ONLY_NS, nsArr, dummy1Arr, dummy1Arr, dummy2Arr);
			
			
			// Get the values out of the arrays!
			ns = nsArr[0];
			
			// If we found a namespace, then create a new ResolvedNsName structure
			// that holds a reference to it.
			
			if (ns != null)
			{
				Namespace currNs = getCurrentNamespace(interp);
				
				ns.refCount++;
				resName = new ResolvedNsName();
				resName.ns = ns;
				resName.nsId = ns.nsId;
				resName.refNs = currNs;
				resName.refCount = 1;
			}
			else
			{
				resName = null;
			}
			
			// By setting the new internal rep we free up the old one.
			
			// FIXME : should a NamespaceCmd wrap a ResolvedNsName?
			// this is confusing because it seems like the C code uses
			// a ResolvedNsName like it is the InternalRep.
			
			NamespaceCmd wrap = new NamespaceCmd();
			wrap.otherValue = resName;
			tobj.InternalRep = wrap;
			
			return ;
		}