Skip to content
Snippets Groups Projects
Select Git revision
  • f5cf311aa8a6707da653a63a0ca091d06abe0c91
  • master default protected
  • 9.0
  • 8.0
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • nt-tools
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
  • v8.0.1982
  • v8.0.1980
  • v8.0.1978
  • v8.0.1976
  • v8.0.1974
  • v8.0.1972
  • v8.0.1970
  • v8.0.1968
  • v8.0.1966
41 results

docode.h

Blame
    • Fredrik Hübinette (Hubbe)'s avatar
      19aaeb43
      made it possible to set index in strings · 19aaeb43
      Fredrik Hübinette (Hubbe) authored
      Rev: lib/modules/Yabu.pmod/test.pike:1.3
      Rev: src/builtin_functions.c:1.111
      Rev: src/docode.c:1.38
      Rev: src/docode.h:1.7
      Rev: src/interpret.c:1.85
      Rev: src/main.c:1.53
      Rev: src/module_support.c:1.12
      Rev: src/object.c:1.52
      Rev: src/operators.c:1.33
      Rev: src/operators.h:1.5
      Rev: src/stralloc.c:1.36
      Rev: src/stralloc.h:1.16
      Rev: src/testsuite.in:1.114
      19aaeb43
      History
      made it possible to set index in strings
      Fredrik Hübinette (Hubbe) authored
      Rev: lib/modules/Yabu.pmod/test.pike:1.3
      Rev: src/builtin_functions.c:1.111
      Rev: src/docode.c:1.38
      Rev: src/docode.h:1.7
      Rev: src/interpret.c:1.85
      Rev: src/main.c:1.53
      Rev: src/module_support.c:1.12
      Rev: src/object.c:1.52
      Rev: src/operators.c:1.33
      Rev: src/operators.h:1.5
      Rev: src/stralloc.c:1.36
      Rev: src/stralloc.h:1.16
      Rev: src/testsuite.in:1.114
    constants.c 2.52 KiB
    /*\
    ||| This file a part of Pike, and is copyright by Fredrik Hubinette
    ||| Pike is distributed as GPL (General Public License)
    ||| See the files COPYING and DISCLAIMER for more information.
    \*/
    #include "global.h"
    #include "constants.h"
    #include "macros.h"
    #include "program.h"
    #include "pike_types.h"
    #include "stralloc.h"
    #include "memory.h"
    #include "interpret.h"
    #include "mapping.h"
    
    static INT32 num_callable=0;
    static struct mapping *builtin_constants = 0;
    
    struct mapping *get_builtin_constants()
    {
      if(!builtin_constants)
        builtin_constants=allocate_mapping(20);
    
      return builtin_constants;
    }
    
    void low_add_efun(struct pike_string *name, struct svalue *fun)
    {
      struct svalue s;
    
      if(!builtin_constants)
        builtin_constants=allocate_mapping(20);
    
      s.type=T_STRING;
      s.subtype=0;
      s.u.string=name;
    
      if(fun)
      {
        mapping_insert(builtin_constants, &s, fun);
      }else{
        map_delete(builtin_constants, &s);
      }
    }
    
    void low_add_constant(char *name, struct svalue *fun)
    {
      struct pike_string *p;
      p=make_shared_string(name);
      low_add_efun(p, fun);
      free_string(p);
    }
    
    void add_global_program(char *name, struct program *p)
    {
      struct svalue s;
      s.type=T_PROGRAM;
      s.subtype=0;
      s.u.program=p;
      low_add_constant(name, &s);
    }
    
    struct callable *make_callable(c_fun fun,
    			       char *name,
    			       char *type,
    			       INT16 flags,
    			       optimize_fun optimize,
    			       docode_fun docode)
    {
      struct callable *f;
      f=ALLOC_STRUCT(callable);
      num_callable++;
      f->refs=1;
      f->function=fun;
      f->name=make_shared_string(name);
      f->type=parse_type(type);
      f->flags=flags;
      f->docode=docode;
      f->optimize=optimize;
      return f;
    }
    
    void really_free_callable(struct callable *fun)
    {
      free_string(fun->type);
      free_string(fun->name);
      free((char *)fun);
      num_callable--;
    }
    
    void add_efun2(char *name,
    	       c_fun fun,
    	       char *type,
    	       INT16 flags,
    	       optimize_fun optimize,
    	       docode_fun docode)
    {
      struct svalue s;
      struct pike_string *n;
    
      n=make_shared_string(name);
      s.type=T_FUNCTION;
      s.subtype=FUNCTION_BUILTIN;
      s.u.efun=make_callable(fun, name, type, flags, optimize, docode);
      low_add_efun(n, &s);
      free_svalue(&s);
      free_string(n);
    }
    
    void add_efun(char *name, c_fun fun, char *type, INT16 flags)
    {
      add_efun2(name,fun,type,flags,0,0);
    }
    
    void cleanup_added_efuns()
    {
      if(builtin_constants)
      {
        free_mapping(builtin_constants);
        builtin_constants=0;
      }
    }
    void count_memory_in_callables(INT32 *num_, INT32 *size_)
    {
      *num_=num_callable;
      *size_=num_callable*sizeof(struct callable);
    }