• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Private GUI Callbacks and SKILL++

Stats

  • Locked Locked
  • Replies 10
  • Subscribers 143
  • Views 16499
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Private GUI Callbacks and SKILL++

Curtisma
Curtisma over 6 years ago

Hello:

I am trying to create a SKILL++ package that includes a form gui.  I setup a gui using a public function of the package.  My plan was to have the callback functions for the gui elements remain private as part of the package and then only make the function to create and open the gui public.  However when I try this I cannot get it to recognize the private functions.  Is there any way I can keep the callback functions private to the package and still run the gui?

I've tried several ways of specifying the callback function when creating the field.  These include trying a string call the private function, a symbol for it, and including the package name in the call. (packageName->selectFileCB) None have fixed the scope issue.

packageName = let(

...

procedure( createGui(L C V)

...

   hiCreateButton(
   ?name 'SelectFileButton
   ?buttonText "Browse"
   ?callback "SelectFileCB('hiGetCurrentForm())")

...

) ; procedure createGui

procedure( selectFileCB()

...

) ; procedure selectFileCB....

) ; let

list(nil 'createGui createGui))

Start Gui:

packageName->createGui()

Gui starts but the callbacks don't work.

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago

    The callbacks are evaluated in the global scope, so that's why it can't see your lexically scoped callback function. From IC617 onwards, you can specify most of the UI callbacks as function objects rather than a SKILL expression or the name of a function, so that allows you to pass the function object accessed via a lexical scope to be the callback - and then since the UI now has the function object, it will be called in the correct scope.

    Details on how to specify function objects as callbacks can be found in the Cadence User Interface SKILL Reference manual, in Chapter 1, in a section headed Function Object Callbacks.

    Here's a simple example I just put together based on your outline:

    ; ensure this is in a file with a .ils suffix
    myPackage=let(()
      procedure(createGUI()
        hiDisplayForm(
          hiCreateAppForm(
    	?name 'forumGUI
    	?fields
              list(
                list(
                  hiCreateStringField(
                    ?name 'name 
                    ?prompt "Name"
                  )
                  0:0 400:30 100)
                list(
                  hiCreateButton(
                    ?name 'button
                    ?buttonText "Press me"
                    ; pass the callback as a function object rather than
                    ; the name of the function or a SKILL expression
                    ?callback buttonCB
                  )
                  100:30 150:30)
              )
          )
        )
      )
      procedure(buttonCB(field scope)
        printf("Button pressed - field:%L scope:%L\n"
          field scope
        )
      )
      list(nil 'createGUI createGUI)
    )

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Curtisma
    Curtisma over 6 years ago in reply to Andrew Beckett

    Perfect!  Got it working.  Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Curtisma
    Curtisma over 6 years ago in reply to Andrew Beckett

    Is there a way to make the deRegApp callbacks private?  Can I use a function object as the callback there also?

    -Curtis

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RK56
    RK56 over 6 years ago in reply to Andrew Beckett

    Hi,

    Once all questions of Curtis are answered, I would like to understand how loading this file in SKILL++ context helps here. What is the we have achieved here by going for SKILL++ instead of just SKILL?

    I have read Jim Newton's SKILL++ blog but still I miss something. Any help here?

    -Ramakrishnan

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Curtisma
    Curtisma over 6 years ago in reply to Andrew Beckett

    Also, is there a way to declare a file to be read as skill++ without setting the extension.  Specifically I'm thinking about situations lwhere we don't have the option to change the file name.  For example, can we use SKILL++ in the .cdsinit or the library manager init file.  

    Should I just include toplevel( 'ils ) at the top of my .cdsinit file to get it to use SKILL++?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Curtisma
    Curtisma over 6 years ago in reply to RK56

    Here I am trying to encapsulate my code so only a well-defined interface is made public.  This allows me to hide implementation details and avoids cluttering the top-level namespace.  SKILL++ also enables the use of an object-oriented programming methodology with the SKILL++ object system.  This can be used to improve the maintainability of the code and encourages reuse of code.  SKILL++ brings some modern software engineering techniques to SKILL.  

    Now if only there was some type of testing framework and a modern IDE...

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Curtisma

    Curtisma said:

    Is there a way to make the deRegApp callbacks private?  Can I use a function object as the callback there also?

    Hi Curtis,

    No. These callbacks currently have to be specified as the symbol for the name of the function. There may well be an enhancement request to change this (I didn't check as I'm on vacation this week), but it would be worth you contacting customer support to request this.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Curtisma

    For Ramakrishnan - one of the key benefits (other than the object system) is that SKILL++ provides lexical scoping rather than SKILL's dynamic scoping. That then enables local functions (so a function defined within a surrounding let is not visible outside by default) - and you can share private data between multiple functions in the same lexical scope. This allows creation of closures, packages and so on.

    There is an IDE (a relatively recent addition - it's got a lot better in recent versions). Not as advanced as some IDEs for other languages, maybe, but a step in the right direction. As for testing frameworks, it's reasonably easy to build your own of course...

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Curtisma
    Curtisma said:
    Should I just include toplevel( 'ils ) at the top of my .cdsinit file to get it to use SKILL++?

    You can't just put toplevel('ils) at the top of your file - that won't work. You can surround your code with inScheme() though:

    inScheme(
      ; your SKILL++ code sitting in a file read with SKILL semantics
    )

    Similarly there's an inSkill macro for the opposite.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Curtisma
    Curtisma over 6 years ago in reply to Andrew Beckett

    Andrew:

    I assume your team some sort of SKILL testing framework.  Do you have anything you can share so I don't have to reinvent the wheel? If not, any suggestions on starting one?

    -Curtis

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information