root/src/obj_io.c

Revision 1ffd3187f60715d349b1be1c5328479b50dda298, 2.7 kB (checked in by redbrain <redbrain@…>, 2 years ago)

cleanups

  • Property mode set to 100644
Line 
1/**
2 * obj_io.c -> Part of Crules Programming language
3 *
4 * Crules is the legal property of its developers. Please refer to the
5 * COPYRIGHT file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21#ifdef HAVE_CONFIG_H
22# include "config.h"
23#else
24# define CMAKE 1
25# include "config.h.cmake"
26#endif
27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31
32#include <crules/crules.h>
33#include <crules/opcodes.h>
34#include <crules/symbols.h>
35#include <crules/objects.h>
36#include <crules/backend.h>
37#include <crules/runtime.h>
38#include <crules/garbage.h>
39#include <crules/operators.h>
40
41// the stdio object is a static object
42void *
43crl_obj_io_stdio_init( crl_symbol_obj * caller,
44                       crl_type_obj_def_t ** def )
45{
46  return NULL;
47}
48
49crl_symbol_obj *
50crl_obj_io_stdio_print( crl_symbol_obj * caller, crl_symbol_obj * self,
51                        crl_context_table * caller_ctx,
52                        crl_context_table * function_ctx )
53{
54  // this is the fprintf( stdout, "..." )
55  printf("\nwhoop!\n\n");
56  return NULL;
57}
58
59bool crl_obj_io_stdio_print__( void * self, FILE * fd,
60                               bool newline )
61{
62  bool retval = true;
63  fprintf( fd, "%p", (void *) self );
64  if( newline )
65    {
66      fprintf( fd, "\n" );
67    }
68  return retval;
69}
70
71void crl_obj_io_stdio_destroy( void * self )
72{
73  // nothing to free there is no builtin type!
74  return;
75}
76
77struct crl_number_prot_t stdio_module_binary_ops = {
78  false,
79  NULL,
80  NULL,
81  NULL,
82  NULL,
83  NULL,
84  NULL,
85  NULL,
86  NULL,
87  NULL,
88  NULL,
89  NULL,
90  NULL,
91  NULL,
92};
93
94struct crl_builtin_function_def_t stdio_module_function_table[] = {
95  { "print", 1, &crl_obj_io_stdio_print },
96  { NULL, 0, NULL },
97} ;
98
99struct crl_builtin_member_def_t stdio_module_member_table[] = {
100  { 0, NULL },
101} ;
102
103struct crl_type_obj_def_t stdio_object = {
104  "Stdio",
105  0,
106  &crl_obj_io_stdio_init,
107  &crl_obj_io_stdio_destroy,
108  &crl_obj_io_stdio_print__,
109  NULL,
110  &stdio_module_binary_ops,
111  stdio_module_member_table,
112  stdio_module_function_table,
113  true,
114} ;
115
116
117bool crl_obj_io_stdio_module_init( crl_context_table * context )
118{
119  bool retval = false;
120  retval = crl_rr_context_intilize_module( &stdio_object, context );
121  return retval;
122}
Note: See TracBrowser for help on using the browser.