github.com/goplus/llgo@v0.8.3/py/func.go (about)

     1  /*
     2   * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package py
    18  
    19  import (
    20  	_ "unsafe"
    21  )
    22  
    23  // https://docs.python.org/3/c-api/function.html
    24  
    25  // Return a new function object associated with the code object code.
    26  // globals must be a dictionary with the global variables accessible
    27  // to the function.
    28  //
    29  // The function’s docstring and name are retrieved from the code object.
    30  // __module__ is retrieved from globals. The argument defaults, annotations
    31  // and closure are set to nil. __qualname__ is set to the same value as
    32  // the code object’s co_qualname field.
    33  //
    34  //go:linkname NewFunc C.PyFunction_New
    35  func NewFunc(code, globals *Object) *Object
    36  
    37  // As NewFunc, but also allows setting the function object’s __qualname__
    38  // attribute. qualname should be a unicode object or nil; if nil, the
    39  // __qualname__ attribute is set to the same value as the code object’s
    40  // co_qualname field.
    41  //
    42  //go:linkname NewFuncWithQualName C.PyFunction_NewWithQualName
    43  func NewFuncWithQualName(code, globals, qualname *Object) *Object
    44  
    45  /*
    46  // Return true if o is a function object (has type PyFunction_Type). The
    47  // parameter must not be nil. This function always succeeds.
    48  //
    49  // llgo:link (*Object).FuncCheck C.PyFunction_Check
    50  func (o *Object) FuncCheck() c.Int { return 0 }
    51  */
    52  
    53  // Return the code object associated with the function object op.
    54  //
    55  // llgo:link (*Object).FuncCode C.PyFunction_GetCode
    56  func (f *Object) FuncCode() *Object { return nil }