/* ************************************************************ */ SOM_Scope void SOMLINK epProcessEnvironment(header somSelf) { /* headerData *somThis = headerGetData(somSelf); */ page thisPage; textLine thisHd; TPWord thisWord; headerMethodDebug("header", "epProcessEnvironment"); thisPage = __get_currentPage(somSelf); thisHd = _pgGetHeaderBlock(thisPage); for (;;) { thisWord = readToken(__get_currentFileMgr(somSelf)); if (_match(thisWord, "[[end_environment]]")) { _somFree(thisWord); return; } if (_tpwType(thisWord) == TP_LINE_BREAK) { _somFree(thisWord); continue; } _llAddTail(thisHd, thisWord); if (_match(thisWord, "[[page_number]]")) _pgSetPageNumber(thisPage, thisWord); } }
SOMEXTERN FILE *emit(char *file, Entry * cls, Stab * stab) { FILE * fp; FILE * deffile; SOMTClassEntryC * oCls; SOMTModuleEntryC * mod; DEFEmitter *emitter; SOMTTemplateOutputC *t; if (cls->type == SOMTClassE) { file=strcat(file, ""); fp = somtopenEmitFile(file, "def"); oCls = (SOMTClassEntryC *) somtGetObjectWrapper(cls); emitter = DEFEmitterNew(); __set_somtTargetFile(emitter, fp); __set_somtTargetClass(emitter, oCls); __set_somtEmitterName(emitter, "def"); t = __get_somtTemplate(emitter); __set_somtCommentStyle(t, somtCPPE); if (deffile = _somtOpenSymbolsFile(emitter, SYMBOLS_FILE, "r")) { _somtReadSectionDefinitions(t, deffile); somtfclose(deffile); } else { exit(-1); } _somtGenerateSections(emitter); _somFree(emitter); _somFree(oCls); return (fp); } else if (cls->type == SOMTModuleE) { fp = somtopenEmitFile(file, "def"); mod = (SOMTModuleEntryC *) somtGetObjectWrapper(cls); emitter = DEFEmitterNew(); __set_somtTargetFile(emitter, fp); __set_somtTargetModule(emitter, mod); t = __get_somtTemplate(emitter); __set_somtCommentStyle(t, somtCPPE); if (deffile = _somtOpenSymbolsFile(emitter, SYMBOLS_FILE, "r")) { _somtReadSectionDefinitions(t, deffile); somtfclose(deffile); } else { exit(-1); } _somtGenerateSections(emitter); _somFree(emitter); _somFree(mod); return (fp); } else { return ((FILE *) NULL); } }
/* ************************************************************ */ SOM_Scope void SOMLINK somUninit(txtEnvProcessor somSelf) { txtEnvProcessorData *somThis = txtEnvProcessorGetData(somSelf); txtEnvProcessorMethodDebug("txtEnvProcessor", "somUninit"); if (_thisWord) _somFree(_thisWord); if (_currentLine) _somFree(_currentLine); parent_somUninit(somSelf); }
/* ************************************************************ */ SOM_Scope void SOMLINK epProcessEnvironment(txtEnvProcessor somSelf) { txtEnvProcessorData *somThis = txtEnvProcessorGetData(somSelf); /* Declare local variables. ------------------------ */ page thisPage; fileMgr thisFile; long n = 0; thisPage = __get_currentPage(somSelf); thisFile = __get_currentFileMgr(somSelf); txtEnvProcessorMethodDebug("txtEnvProcessor", "epProcessEnvironment"); /* Prepare for looping. -------------------- */ _epInitializeEnvironment(somSelf); /* Loop until end of file. ----------------------- */ while (_thisWord = readToken(thisFile)) { /* _print(_thisWord, stdout); */ if (_tpwType(_thisWord) == TP_EOF) { _somFree(_thisWord); break; } if (_match(_thisWord, "[[end_environment]]")) { _epShutdownEnvironment(somSelf); break; } switch (_tpwType(_thisWord)) { case TP_LINE_BREAK: _tpProcessLineBreak(somSelf); continue; case TP_WORD: _tpProcessWord(somSelf); continue; case TP_PARAGRAPH_BREAK: _tpProcessNewParagraph(somSelf); continue; case TP_BLANK_SPACE: _tpProcessBlanks(somSelf); continue; case TP_TOKEN: _epStartUpNewEnvironment(somSelf, _thisWord); _somFree(_thisWord); continue; } } _tpProcessFullLine(somSelf); }
static void Audio_DeleteDevice(_THIS) { if(this->hidden->playbuf._buffer) free(this->hidden->playbuf._buffer); if(this->hidden->fillbuf._buffer) free(this->hidden->fillbuf._buffer); _somFree( this->hidden->umsdev ); free(this->hidden); free(this); }
static void aix_close(void) { rc = UMSAudioDevice_play_remaining_data(audio_device, ev, TRUE); UMSAudioDevice_stop(audio_device, ev); UMSAudioDevice_close(audio_device, ev); _somFree(audio_device); lib_free(buffer._buffer); audio_device = NULL; }
main(int argc, char *argv[], char *envp[]) { Hello myhello; Environment *ev; ev = somGetGlobalEnvironment(); myhello = HelloNew(); __set_msg(myhello, ev, "Hello World from SOM"); _printHello(myhello,ev); _somFree(myhello); }
SOM_Scope void SOMLINK tpProcessBlanks(txtEnvProcessor somSelf) { txtEnvProcessorData *somThis = txtEnvProcessorGetData(somSelf); textLine thisLine = __get_currentLine(somSelf); txtEnvProcessorMethodDebug("txtEnvProcessor", "tpProcessBlanks"); if (!_tlCharsLeft(thisLine)) { _somFree(_thisWord); return; } _tpProcessWord(somSelf); }
SOM_Scope void SOMLINK tpProcessLineBreak(txtEnvProcessor somSelf) { txtEnvProcessorData *somThis = txtEnvProcessorGetData(somSelf); textLine thisLine = __get_currentLine(somSelf); txtEnvProcessorMethodDebug("txtEnvProcessor", "tpProcessLineBreak"); _somFree(_thisWord); if (!_tlCharsInLine(thisLine)) return; if (!_tlCharsLeft(thisLine)) return; _thisWord = TPWordNew(); _wordInit1(_thisWord, " "); _tpProcessWord(somSelf); }
SOM_Scope void SOMLINK somDestruct(dAnimal somSelf, octet doFree, somDestructCtrl* ctrl) { dAnimalData *somThis; /* set in BeginDestructor */ somDestructCtrl globalCtrl; somBooleanVector myMask; dAnimalMethodDebug("dAnimal","somDestruct"); dAnimal_BeginDestructor; if (_name) SOMFree(_name); if (_type) SOMFree(_type); if (_food) SOMFree(_food); if (_buff) SOMFree(_buff); _somFree(_loc); dAnimal_EndDestructor; }
SOM_Scope void SOMLINK tpProcessNewParagraph(txtEnvProcessor somSelf) { txtEnvProcessorData *somThis = txtEnvProcessorGetData(somSelf); long charsToIndent; TPWord blanks; textLine thisLine; txtEnvProcessorMethodDebug("txtEnvProcessor", "tpProcessNewParagraph"); charsToIndent = __get_paragraphIndentation(somSelf); _tpProcessFullLine(somSelf); _tpProcessNewLine(somSelf); thisLine = __get_currentLine(somSelf); if (charsToIndent) { blanks = TPWordNew(); _wordInit2(blanks, ' ', charsToIndent); _llAddTail(thisLine, (baseType) blanks); } _somFree(_thisWord); }
/* ************************************************************ */ SOM_Scope void SOMLINK epInitializeEnvironment(txtEnvProcessor somSelf) { txtEnvProcessorData *somThis = txtEnvProcessorGetData(somSelf); long charsToIndent; TPWord blanks; TPWord lineFeed; textLine thisLine; fileMgr thisFile; txtEnvProcessorMethodDebug("txtEnvProcessor", "epInitializeEnvironment"); thisFile = __get_currentFileMgr(somSelf); lineFeed = readToken(thisFile); _somFree(lineFeed); charsToIndent = __get_paragraphIndentation(somSelf); _tpProcessNewLine(somSelf); thisLine = __get_currentLine(somSelf); if (charsToIndent) { blanks = TPWordNew(); _wordInit2(blanks, ' ', charsToIndent); _llAddTail(thisLine, (baseType) blanks); } }
static int aix_init(const char *param, int *speed, int *fragsize, int *fragnr, int *channels) { int st, tmp, i; /* No stereo capability. */ *channels = 1; /* open device */ ev = somGetGlobalEnvironment(); audio_device = UMSBAUDDeviceNew(); rc = UMSAudioDevice_open(audio_device, ev, "/dev/paud0", "PLAY", UMSAudioDevice_BlockingIO); if (audio_device == NULL) { fprintf(errfile,"can't create audio device object\nError: %s\n", error_string); return 1; } rc = UMSAudioDevice_set_volume(audio_device, ev, 100); rc = UMSAudioDevice_set_balance(audio_device, ev, 0); rc = UMSAudioDevice_set_time_format(audio_device, ev, UMSAudioTypes_Msecs); if (obyte_order) lib_free(obyte_order); rc = UMSAudioDevice_set_byte_order(audio_device, ev, "LSB"); /* set 16bit */ rc = UMSAudioDevice_set_bits_per_sample(audio_device, ev, 16); rc = UMSAudioDevice_set_audio_format_type(audio_device, ev, "PCM"); rc = UMSAudioDevice_set_number_format(audio_device, ev, "TWOS_COMPLEMENT"); /* set speed */ rc = UMSAudioDevice_set_sample_rate(audio_device, ev, *speed, &out_rate); /* channels */ rc = UMSAudioDevice_set_number_of_channels(audio_device, ev, 1); /* should we use the default? */ left_gain = right_gain = 100; rc = UMSAudioDevice_enable_output(audio_device, ev, "LINE_OUT", &left_gain, &right_gain); /* set buffer size */ tmp = (*fragsize) * (*fragnr) * sizeof(SWORD); buffer._maximum = tmp; buffer._buffer = (char *)lib_malloc(tmp); buffer._length = 0; rc = UMSAudioDevice_initialize(audio_device, ev); rc = UMSAudioDevice_start(audio_device, ev); return 0; #if 0 /* XXX: AIX: everything should check rc, this isn't used now */ fail: UMSAudioDevice_stop(audio_device, ev); UMSAudioDevice_close(audio_device, ev); _somFree(audio_device); lib_free(buffer._buffer); audio_device = NULL; return 1; #endif }